Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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|
|
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
|
19 |
response += f"<span style='background-color:#b8e994; color:black;'>{label}</span>: {score:.3f}<br>" # Light Green
|
20 |
-
|
21 |
response += f"<span style='background-color:#fff3cd; color:black;'>{label}</span>: {score:.3f}<br>" # Light Yellow
|
22 |
-
|
23 |
response += f"<span style='background-color:#bee5eb; color:black;'>{label}</span>: {score:.3f}<br>" # Light Blue
|
24 |
-
|
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'>
|