Aidan Phillips commited on
Commit
7f92e26
·
1 Parent(s): 968a94a

use words instead of numbers

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -21,6 +21,17 @@ def load_translations():
21
  return None
22
 
23
 
 
 
 
 
 
 
 
 
 
 
 
24
  if "translations" not in st.session_state:
25
  st.session_state.translations = load_translations()
26
 
@@ -37,17 +48,17 @@ def response_generator(prompt):
37
  st.session_state.scores = []
38
  st.session_state.scores.append(total_score)
39
 
40
- response = "Your total translation score is: " + str(total_score) + "\n"
41
 
42
  acc_s = acc["score"]
43
- response += f"\nYour accuracy score is {acc_s}:\n"
44
 
45
  for error in acc["errors"]:
46
  response += f" - {error['message']}\n"
47
 
48
  gre_s = gre["score"]
49
  ppl_s = ppl["score"]
50
- response += f"\nYour fluency score is {0.4 * gre_s + 0.6 * ppl_s}:\n"
51
 
52
  for error in gre["errors"]:
53
  response += f" - {error['message']}\n"
 
21
  return None
22
 
23
 
24
+ def score(score):
25
+ if score > 90:
26
+ return "excellent!"
27
+ elif score > 80:
28
+ return "good."
29
+ elif score > 70:
30
+ return "fair."
31
+ else:
32
+ return "poor."
33
+
34
+
35
  if "translations" not in st.session_state:
36
  st.session_state.translations = load_translations()
37
 
 
48
  st.session_state.scores = []
49
  st.session_state.scores.append(total_score)
50
 
51
+ response = f"Your translation quality was {score(total_score)}\n\n"
52
 
53
  acc_s = acc["score"]
54
+ response += f"\nYour accuracy score is {score(acc_s)}:\n"
55
 
56
  for error in acc["errors"]:
57
  response += f" - {error['message']}\n"
58
 
59
  gre_s = gre["score"]
60
  ppl_s = ppl["score"]
61
+ response += f"\nYour fluency score is {score(0.4 * gre_s + 0.6 * ppl_s)}\n"
62
 
63
  for error in gre["errors"]:
64
  response += f" - {error['message']}\n"