Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,13 +90,18 @@ def analyze_sentiment(text, lang_hint):
|
|
| 90 |
explanation = sentiment_with_tips(sentiment)
|
| 91 |
|
| 92 |
# Save to CSV
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
new_row = pd.DataFrame([[text, lang, sentiment, score]],
|
| 95 |
columns=["Sentence", "Language", "Sentiment", "Confidence"])
|
| 96 |
df = pd.concat([df, new_row], ignore_index=True)
|
| 97 |
-
df.to_csv(SAVE_FILE, index=False)
|
| 98 |
|
| 99 |
-
|
|
|
|
|
|
|
| 100 |
|
| 101 |
# -----------------------------
|
| 102 |
# Gradio UI
|
|
|
|
| 90 |
explanation = sentiment_with_tips(sentiment)
|
| 91 |
|
| 92 |
# Save to CSV
|
| 93 |
+
try:
|
| 94 |
+
df = pd.read_csv(SAVE_FILE, encoding="utf-8-sig")
|
| 95 |
+
except:
|
| 96 |
+
df = pd.DataFrame(columns=["Sentence", "Language", "Sentiment", "Confidence"])
|
| 97 |
+
|
| 98 |
new_row = pd.DataFrame([[text, lang, sentiment, score]],
|
| 99 |
columns=["Sentence", "Language", "Sentiment", "Confidence"])
|
| 100 |
df = pd.concat([df, new_row], ignore_index=True)
|
|
|
|
| 101 |
|
| 102 |
+
# Save with proper encoding for Urdu
|
| 103 |
+
df.to_csv(SAVE_FILE, index=False, encoding="utf-8-sig")
|
| 104 |
+
|
| 105 |
|
| 106 |
# -----------------------------
|
| 107 |
# Gradio UI
|