karalif commited on
Commit
65399fa
·
verified ·
1 Parent(s): 6160f25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -5,7 +5,7 @@ import re
5
  text_pipe = pipeline("text-classification", model="karalif/myTestModel", return_all_scores=True)
6
 
7
  def predict(text):
8
- greeting_pattern = r"^(Halló|Hæ|Sæl|Góða|Kær|Daginn|Kvöldið|Ágæt|Elsku)"
9
 
10
  greeting_feedback = ""
11
 
@@ -15,16 +15,14 @@ def predict(text):
15
  for result in all_scores:
16
  label = result['label']
17
  score = result['score']
18
- if label in ["Politeness"]:
19
  response += f"<span style='background-color:#b8e994; color:black;'>{label}</span>: {score:.3f}<br>" # Light Green
20
- if label in ["Sentiment"]:
21
  response += f"<span style='background-color:#fff3cd; color:black;'>{label}</span>: {score:.3f}<br>" # Light Yellow
22
- if label in ["Formality"]:
23
  response += f"<span style='background-color:#bee5eb; color:black;'>{label}</span>: {score:.3f}<br>" # Light Blue
24
- if label in ["Toxicity"]:
25
  response += f"<span style='background-color:#f8d7da; color:black;'>{label}</span>: {score:.3f}<br>" # Light Red
26
- else:
27
- response += f"{label}: {score:.3f}<br>"
28
 
29
  if not re.match(greeting_pattern, text, re.IGNORECASE):
30
  greeting_feedback = "Heilsaðu dóninn þinn<br>"
@@ -33,6 +31,7 @@ def predict(text):
33
 
34
  return response
35
 
 
36
  description_html = """
37
  <center>
38
  <img src='http://www.ru.is/media/HR_logo_vinstri_transparent.png' width='250' height='auto'>
 
5
  text_pipe = pipeline("text-classification", model="karalif/myTestModel", return_all_scores=True)
6
 
7
  def predict(text):
8
+ greeting_pattern = r"^(Halló|Hæ|Sæl|Góðan dag|Kær kveðja|Daginn|Kvöldið|Ágætis|Elsku)"
9
 
10
  greeting_feedback = ""
11
 
 
15
  for result in all_scores:
16
  label = result['label']
17
  score = result['score']
18
+ if label == "Politeness":
19
  response += f"<span style='background-color:#b8e994; color:black;'>{label}</span>: {score:.3f}<br>" # Light Green
20
+ elif label == "Sentiment":
21
  response += f"<span style='background-color:#fff3cd; color:black;'>{label}</span>: {score:.3f}<br>" # Light Yellow
22
+ elif label == "Formality":
23
  response += f"<span style='background-color:#bee5eb; color:black;'>{label}</span>: {score:.3f}<br>" # Light Blue
24
+ elif label == "Toxicity":
25
  response += f"<span style='background-color:#f8d7da; color:black;'>{label}</span>: {score:.3f}<br>" # Light Red
 
 
26
 
27
  if not re.match(greeting_pattern, text, re.IGNORECASE):
28
  greeting_feedback = "Heilsaðu dóninn þinn<br>"
 
31
 
32
  return response
33
 
34
+
35
  description_html = """
36
  <center>
37
  <img src='http://www.ru.is/media/HR_logo_vinstri_transparent.png' width='250' height='auto'>