Update app.py
Browse files
app.py
CHANGED
|
@@ -18,25 +18,56 @@ current_dir = os.path.dirname(os.path.abspath(__file__))
|
|
| 18 |
font_path = os.path.join(current_dir, "ArabicR2013-J25x.ttf")
|
| 19 |
|
| 20 |
ARABIC_STOP_WORDS = {
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
'
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
'
|
| 27 |
-
'
|
| 28 |
-
'
|
| 29 |
-
'
|
| 30 |
-
'
|
| 31 |
-
'
|
| 32 |
-
'
|
| 33 |
-
'
|
| 34 |
-
'
|
| 35 |
-
|
| 36 |
-
'ุงูุง', 'ุงููู', 'ูู', 'ูู', '
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
}
|
| 38 |
|
| 39 |
|
|
|
|
|
|
|
| 40 |
COUNTRY_MAPPING = {
|
| 41 |
'ู
ุตุฑ': 'Egypt',
|
| 42 |
'ุงูุณุนูุฏูุฉ': 'Saudi Arabia',
|
|
@@ -141,9 +172,17 @@ def create_topic_map(summaries):
|
|
| 141 |
for summary in summaries:
|
| 142 |
country_en = COUNTRY_MAPPING.get(summary['country'])
|
| 143 |
if country_en and country_en in coordinates:
|
| 144 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
dominant_emotion = summary['top_emotions'][0]['emotion'] if summary['top_emotions'] else "Neutral"
|
| 146 |
-
|
|
|
|
| 147 |
|
| 148 |
# Create popup content
|
| 149 |
popup_content = f"""
|
|
|
|
| 18 |
font_path = os.path.join(current_dir, "ArabicR2013-J25x.ttf")
|
| 19 |
|
| 20 |
ARABIC_STOP_WORDS = {
|
| 21 |
+
ARABIC_STOP_WORDS = {
|
| 22 |
+
# First group
|
| 23 |
+
'ูู', 'ู
ู', 'ุฅูู', 'ุนูู', 'ุนูู', 'ุนู', 'ู
ุน', 'ุฎูุงู', 'ุญุชู', 'ุญุชู', 'ุฅุฐุง',
|
| 24 |
+
|
| 25 |
+
# Middle group
|
| 26 |
+
'ุซู
', 'ุฃู', 'ู', 'ู', 'ุจ', 'ู', 'ูู', 'ุงู', 'ูุฐุง',
|
| 27 |
+
'ูุฐู', 'ุฐูู', 'ุชูู', 'ูุคูุงุก', 'ูู
', 'ูู', 'ูู', 'ูู', 'ูุญู',
|
| 28 |
+
'ุงูุช', 'ุงูุชู
', 'ูุงู', 'ูุงูุช', 'ูููู', 'ุชููู', 'ุงู', 'ูู',
|
| 29 |
+
'ุจุนุถ', 'ุบูุฑ', 'ุญูู', 'ุนูุฏ', 'ูุฏ', 'ููุฏ', 'ูู
', 'ูู', 'ูู',
|
| 30 |
+
'ู
ุง', 'ู
ุงุฐุง', 'ู
ุชู', 'ููู', 'ุงูู', 'ูู
ุงุฐุง', 'ุงูุฐู', 'ุงูุชู',
|
| 31 |
+
'ุงูุฐูู', 'ุงููุงุชู', 'ุงูููุงุชู', 'ุงูุงู', 'ุจูู', 'ููู', 'ุชุญุช',
|
| 32 |
+
'ุงู
ุงู
', 'ุฎูู', 'ุญูู', 'ูุจู', 'ุจุนุฏ', 'ุฃู', 'ูู', 'ูู
ุง', 'ููุง',
|
| 33 |
+
'ู
ูุฐ', 'ููุณ', 'ุญูุซ', 'ููุงู', 'ุฌุฏุง', 'ุฐุงุช', 'ุถู
ู', 'ุงูู', 'ูุฏู',
|
| 34 |
+
'ุนููู', 'ู
ุซู', 'ุฃู
ุง', 'ูุฏู', 'ููู', 'ููู
', 'ููู', 'ุงูุถุง', 'ูุงุฒู
',
|
| 35 |
+
'ูุฌุจ', 'ุตุงุฑ', 'ุตุงุฑุช', 'ุถุฏ', 'ูุง', 'ูุง', 'ุงู
ุง',
|
| 36 |
+
'ุจูุง', 'ุงู', 'ุจู', 'ุงูู', 'ูู
ุง', 'ุงูุง', 'ุงููู', 'ูู', 'ูู', 'ููุช',
|
| 37 |
+
|
| 38 |
+
# Middle group prefixed with "ู"
|
| 39 |
+
'ูุซู
', 'ูุฃู', 'ูู', 'ูุจ', 'ูู', 'ููู', 'ูุงู',
|
| 40 |
+
'ููุฐุง', 'ููุฐู', 'ูุฐูู', 'ูุชูู', 'ููุคูุงุก', 'ููู
', 'ููู', 'ููู', 'ููู', 'ููุญู',
|
| 41 |
+
'ูุงูุช', 'ูุงูุชู
', 'ููุงู', 'ููุงูุช', 'ููููู', 'ูุชููู', 'ูุงู', 'ููู',
|
| 42 |
+
'ูุจุนุถ', 'ูุบูุฑ', 'ูุญูู', 'ูุนูุฏ', 'ููุฏ', 'ูููุฏ', 'ููู
', 'ููู', 'ููู',
|
| 43 |
+
'ูู
ุง', 'ูู
ุงุฐุง', 'ูู
ุชู', 'ูููู', 'ูุงูู', 'ููู
ุงุฐุง', 'ูุงูุฐู', 'ูุงูุชู',
|
| 44 |
+
'ูุงูุฐูู', 'ูุงููุงุชู', 'ูุงูููุงุชู', 'ูุงูุงู', 'ูุจูู', 'ูููู', 'ูุชุญุช',
|
| 45 |
+
'ูุงู
ุงู
', 'ูุฎูู', 'ูุญูู', 'ููุจู', 'ูุจุนุฏ', 'ูุฃู', 'ููู', 'ููู
ุง', 'ูููุง',
|
| 46 |
+
'ูู
ูุฐ', 'ูููุณ', 'ูุญูุซ', 'ูููุงู', 'ูุฌุฏุง', 'ูุฐุงุช', 'ูุถู
ู', 'ูุงูู', 'ููุฏู',
|
| 47 |
+
'ูุนููู', 'ูู
ุซู', 'ูุฃู
ุง', 'ูููู', 'ูููู
', 'ูููู', 'ูุงูุถุง', 'ููุงุฒู
',
|
| 48 |
+
'ููุฌุจ', 'ูุตุงุฑ', 'ูุตุงุฑุช', 'ูุถุฏ', 'ููุง', 'ููุง', 'ูุงู
ุง',
|
| 49 |
+
'ูุจูุง', 'ูุงู', 'ูุจู', 'ูุงูู', 'ููู
ุง', 'ูุงูุง', 'ูุงููู', 'ููู', 'ููู', 'ูููุช',
|
| 50 |
+
|
| 51 |
+
# Last group
|
| 52 |
+
'ููู', 'ูู
ู', 'ูุนูู', 'ูุนูู', 'ูุนู', 'ูู
ุน', 'ูุญุชู', 'ูุฅุฐุง',
|
| 53 |
+
'ููุฐุง', 'ููุฐู', 'ูุฐูู', 'ูุชูู', 'ููู', 'ููู', 'ููุญู',
|
| 54 |
+
'ููุงู', 'ููุงูุช', 'ููู', 'ูุจุนุถ', 'ูุญูู', 'ูุนูุฏ', 'ููุฏ',
|
| 55 |
+
'ูููุฏ', 'ููู
', 'ููู', 'ูู
ุง', 'ูููู', 'ูุงูู', 'ูุงูุฐู',
|
| 56 |
+
'ูุจูู', 'ููุจู', 'ูุจุนุฏ', 'ููู', 'ูููุง', 'ูููุงู', 'ูุงูู',
|
| 57 |
+
'ููุฏู', 'ูุนููู', 'ูู
ุซู',
|
| 58 |
+
|
| 59 |
+
# Arabic numbers
|
| 60 |
+
'ูุงุญุฏ', 'ุงุซูุงู', 'ุซูุงุซุฉ', 'ุฃุฑุจุนุฉ', 'ุฎู
ุณุฉ', 'ุณุชุฉ', 'ุณุจุนุฉ',
|
| 61 |
+
'ุซู
ุงููุฉ', 'ุชุณุนุฉ', 'ุนุดุฑุฉ',
|
| 62 |
+
|
| 63 |
+
# Arabic ordinals
|
| 64 |
+
'ุงูุฃูู', 'ุงูุซุงูู', 'ุงูุซุงูุซ', 'ุงูุฑุงุจุน', 'ุงูุฎุงู
ุณ', 'ุงูุณุงุฏุณ',
|
| 65 |
+
'ุงูุณุงุจุน', 'ุงูุซุงู
ู', 'ุงูุชุงุณุน', 'ุงูุนุงุดุฑ'
|
| 66 |
}
|
| 67 |
|
| 68 |
|
| 69 |
+
|
| 70 |
+
|
| 71 |
COUNTRY_MAPPING = {
|
| 72 |
'ู
ุตุฑ': 'Egypt',
|
| 73 |
'ุงูุณุนูุฏูุฉ': 'Saudi Arabia',
|
|
|
|
| 172 |
for summary in summaries:
|
| 173 |
country_en = COUNTRY_MAPPING.get(summary['country'])
|
| 174 |
if country_en and country_en in coordinates:
|
| 175 |
+
# Mapping emotions back to their original labels
|
| 176 |
+
REVERSE_EMOTION_LABELS = {
|
| 177 |
+
'Negative': 'LABEL_0',
|
| 178 |
+
'Positive': 'LABEL_1',
|
| 179 |
+
'Neutral': 'LABEL_2'
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
# Get dominant sentiment and map it back to original label
|
| 183 |
dominant_emotion = summary['top_emotions'][0]['emotion'] if summary['top_emotions'] else "Neutral"
|
| 184 |
+
dominant_label = REVERSE_EMOTION_LABELS.get(dominant_emotion, 'LABEL_2')
|
| 185 |
+
circle_color = sentiment_colors.get(dominant_label, 'gray')
|
| 186 |
|
| 187 |
# Create popup content
|
| 188 |
popup_content = f"""
|