Tirath5504 commited on
Commit
c21feb8
·
verified ·
1 Parent(s): 968eba7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -20
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.2,
21
- "unique_key_points": 0.8,
22
- "strength_word_count": 0.002,
23
- "weakness_word_count": 0.004,
24
- "discussion_word_count": 0.01
25
  }
26
 
 
 
 
 
27
  THRESHOLDS = {
28
- "normalized_length": (0.15, 0.25),
29
- "unique_key_points": (3, 10),
30
- "information_density": (0.01, 0.02),
31
- "unique_insights_per_word": 0.002,
32
- "optimization_score": 0.7,
33
- "composite_score": 5,
34
- "adjusted_argument_strength": 0.75
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
- if row['composite_score'] > 12:
168
- return 'Excellent Review Quality'
169
- elif row['composite_score'] < 3:
170
- return 'Poor Review Quality'
 
171
  else:
172
- return 'Moderate Review Quality'
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["composite_score"] < THRESHOLDS["composite_score"]:
213
- suggestions.append("Enhance clarity, evidence, and argumentation.")
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="A framework which dynamically provides suggestion to improve a peer review.",
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__":