Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,11 +15,14 @@ def predict(text):
|
|
| 15 |
for result in all_scores:
|
| 16 |
label = result['label']
|
| 17 |
score = result['score']
|
| 18 |
-
#
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
if not re.match(greeting_pattern, text, re.IGNORECASE):
|
| 22 |
-
greeting_feedback = "
|
| 23 |
|
| 24 |
response += greeting_feedback
|
| 25 |
|
|
@@ -35,7 +38,7 @@ textbox = gr.Textbox()
|
|
| 35 |
demo = gr.Interface(
|
| 36 |
fn=predict,
|
| 37 |
inputs=gr.TextArea(label="Enter text here:"),
|
| 38 |
-
outputs=
|
| 39 |
description=description_html,
|
| 40 |
examples=[
|
| 41 |
["Það voru vitni að árásinni sem tilkynntu málið til lögreglu sem kom skjótt á vettvang."],
|
|
@@ -44,7 +47,7 @@ demo = gr.Interface(
|
|
| 44 |
["Hver á þenan bússtað? já eða nei."],
|
| 45 |
["Hafi þau svo látið gólfið þorna vel og síðan flotað það til lagfæringar eftir motturnar."],
|
| 46 |
],
|
| 47 |
-
theme
|
| 48 |
)
|
| 49 |
|
| 50 |
-
demo.launch()
|
|
|
|
| 15 |
for result in all_scores:
|
| 16 |
label = result['label']
|
| 17 |
score = result['score']
|
| 18 |
+
# Apply special styling only for "Politeness", "Sentiment", "Formality"
|
| 19 |
+
if label in ["Politeness", "Sentiment", "Formality"]:
|
| 20 |
+
response += f"<span style='background-color:green; color:black;'>{label}: {score:.3f}</span><br>"
|
| 21 |
+
else:
|
| 22 |
+
response += f"{label}: {score:.3f}<br>"
|
| 23 |
|
| 24 |
if not re.match(greeting_pattern, text, re.IGNORECASE):
|
| 25 |
+
greeting_feedback = "Heilsaðu dóninn þinn<br>"
|
| 26 |
|
| 27 |
response += greeting_feedback
|
| 28 |
|
|
|
|
| 38 |
demo = gr.Interface(
|
| 39 |
fn=predict,
|
| 40 |
inputs=gr.TextArea(label="Enter text here:"),
|
| 41 |
+
outputs=gr.HTML(label="Leiðrétt"),
|
| 42 |
description=description_html,
|
| 43 |
examples=[
|
| 44 |
["Það voru vitni að árásinni sem tilkynntu málið til lögreglu sem kom skjótt á vettvang."],
|
|
|
|
| 47 |
["Hver á þenan bússtað? já eða nei."],
|
| 48 |
["Hafi þau svo látið gólfið þorna vel og síðan flotað það til lagfæringar eftir motturnar."],
|
| 49 |
],
|
| 50 |
+
theme=gr.themes.Default(primary_hue="red", secondary_hue="pink")
|
| 51 |
)
|
| 52 |
|
| 53 |
+
demo.launch()
|