Update app.py
Browse files
app.py
CHANGED
|
@@ -17,21 +17,25 @@ nlp = spacy.load("en_core_web_sm")
|
|
| 17 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 18 |
|
| 19 |
weights = {
|
| 20 |
-
"information_density": 0.
|
| 21 |
-
"unique_key_points": 0.
|
| 22 |
-
"strength_word_count": 0.
|
| 23 |
-
"weakness_word_count": 0.
|
| 24 |
-
"discussion_word_count": 0.
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
THRESHOLDS = {
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
}
|
| 36 |
|
| 37 |
def chunk_text(text, max_length):
|
|
@@ -164,12 +168,13 @@ def calculate_composite_score(df):
|
|
| 164 |
return df
|
| 165 |
|
| 166 |
def classify_review_quality(row):
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
| 171 |
else:
|
| 172 |
-
return 'Moderate
|
| 173 |
|
| 174 |
def determine_review_quality(df):
|
| 175 |
|
|
@@ -209,8 +214,8 @@ def heuristic_optimization(row):
|
|
| 209 |
elif row["unique_key_points"] > THRESHOLDS["unique_key_points"][1]:
|
| 210 |
suggestions.append("Streamline ideas for clarity.")
|
| 211 |
|
| 212 |
-
if row["
|
| 213 |
-
suggestions.append("
|
| 214 |
|
| 215 |
if row["review_quality"] == "Low":
|
| 216 |
suggestions.append("Significant revisions required.")
|
|
@@ -241,7 +246,7 @@ iface = gr.Interface(
|
|
| 241 |
inputs=[gr.Textbox(label="Peer Review Comments"), gr.Textbox(label="Paper Abstract")],
|
| 242 |
outputs=[gr.Textbox(label="Predicted Review Quality"), gr.Textbox(label="Suggestions")],
|
| 243 |
title="# Dynamic Length Optimization of Peer Review",
|
| 244 |
-
description="
|
| 245 |
)
|
| 246 |
|
| 247 |
if __name__ == "__main__":
|
|
|
|
| 17 |
model = SentenceTransformer('all-MiniLM-L6-v2')
|
| 18 |
|
| 19 |
weights = {
|
| 20 |
+
"information_density": 0.1468,
|
| 21 |
+
"unique_key_points": 0.8323,
|
| 22 |
+
"strength_word_count": 0.0034,
|
| 23 |
+
"weakness_word_count": 0.0047,
|
| 24 |
+
"discussion_word_count": 0.0127
|
| 25 |
}
|
| 26 |
|
| 27 |
+
# Dynamic thresholds derived via GMM
|
| 28 |
+
THRESH_POOR = 4.5941101516587315
|
| 29 |
+
THRESH_EXCELLENT = 10.581525294084457
|
| 30 |
+
|
| 31 |
THRESHOLDS = {
|
| 32 |
+
"normalized_length": (0.1510989010989011, 0.3722527472527472),
|
| 33 |
+
"unique_key_points": (2.0, 5.0),
|
| 34 |
+
"information_density": (0.00727669710202455, 0.011291644452510826),
|
| 35 |
+
"unique_insights_per_word": 13.607476635514018,
|
| 36 |
+
"optimization_score": 0.032395506665225886,
|
| 37 |
+
"composite_score": (4.5941101516587315, 10.581525294084457),
|
| 38 |
+
"adjusted_argument_strength": 0.0616150390018116,
|
| 39 |
}
|
| 40 |
|
| 41 |
def chunk_text(text, max_length):
|
|
|
|
| 168 |
return df
|
| 169 |
|
| 170 |
def classify_review_quality(row):
|
| 171 |
+
cs = row['composite_score']
|
| 172 |
+
if cs < THRESH_POOR:
|
| 173 |
+
return 'Poor'
|
| 174 |
+
elif cs > THRESH_EXCELLENT:
|
| 175 |
+
return 'Excellent'
|
| 176 |
else:
|
| 177 |
+
return 'Moderate'
|
| 178 |
|
| 179 |
def determine_review_quality(df):
|
| 180 |
|
|
|
|
| 214 |
elif row["unique_key_points"] > THRESHOLDS["unique_key_points"][1]:
|
| 215 |
suggestions.append("Streamline ideas for clarity.")
|
| 216 |
|
| 217 |
+
if row["optimization_score"] < THRESHOLDS["optimization_score"]:
|
| 218 |
+
suggestions.append("Restructure content and improve phrasing.")
|
| 219 |
|
| 220 |
if row["review_quality"] == "Low":
|
| 221 |
suggestions.append("Significant revisions required.")
|
|
|
|
| 246 |
inputs=[gr.Textbox(label="Peer Review Comments"), gr.Textbox(label="Paper Abstract")],
|
| 247 |
outputs=[gr.Textbox(label="Predicted Review Quality"), gr.Textbox(label="Suggestions")],
|
| 248 |
title="# Dynamic Length Optimization of Peer Review",
|
| 249 |
+
description="Predicts review quality and suggests improvements.",
|
| 250 |
)
|
| 251 |
|
| 252 |
if __name__ == "__main__":
|