Update app.py
Browse files
app.py
CHANGED
@@ -49,80 +49,61 @@ tone_categories = {
|
|
49 |
|
50 |
# Frame categories for fallback method
|
51 |
|
|
|
52 |
frame_categories = {
|
53 |
"Human Rights & Justice": {
|
54 |
-
"Legal Rights & Reforms": ["law", "justice", "legal", "reforms", "legislation"],
|
55 |
-
"Humanitarian Issues": ["humanitarian", "aid", "refugees", "asylum", "crisis response"],
|
56 |
-
"Civil Liberties": ["freedom", "expression", "privacy", "rights violations"]
|
57 |
},
|
58 |
"Political & State Accountability": {
|
59 |
-
"Corruption & Governance": ["corruption", "government", "policy", "accountability", "transparency"],
|
60 |
-
"Political Oppression": ["authoritarianism", "censorship", "state control", "dissent", "crackdown"],
|
61 |
-
"Elections & Political Representation": ["voting", "elections", "political participation", "democracy"]
|
62 |
},
|
63 |
"Gender & Patriarchy": {
|
64 |
-
"Gender-Based Violence": ["violence", "domestic abuse", "sexual harassment", "femicide"],
|
65 |
-
"Women's Rights & Equality": ["gender equality", "feminism", "reproductive rights", "patriarchy"],
|
66 |
-
"LGBTQ+ Rights": ["queer rights", "LGBTQ+", "gender identity", "trans rights", "homophobia"]
|
67 |
},
|
68 |
"Religious Freedom & Persecution": {
|
69 |
-
"Religious Discrimination": ["persecution", "intolerance", "sectarianism", "faith-based violence"],
|
70 |
-
"Religious Minorities' Rights": ["minorities", "blasphemy laws", "religious freedom", "forced conversion"]
|
71 |
},
|
72 |
"Grassroots Mobilization": {
|
73 |
-
"Community Activism": ["activism", "grassroots", "volunteering", "local organizing"],
|
74 |
-
"Protests & Demonstrations": ["march", "strike", "rally", "sit-in", "boycott"],
|
75 |
-
"Coalition Building": ["solidarity", "collaboration", "alliances", "mutual aid"]
|
76 |
},
|
77 |
"Environmental Crisis & Activism": {
|
78 |
-
"Climate Change Awareness": ["climate crisis", "global warming", "carbon emissions", "fossil fuels"],
|
79 |
-
"Conservation & Sustainability": ["deforestation", "wildlife protection", "biodiversity"],
|
80 |
-
"Environmental Justice": ["pollution", "water crisis", "land rights", "indigenous rights"]
|
81 |
},
|
82 |
"Anti-Extremism & Anti-Violence": {
|
83 |
-
"Hate Speech & Radicalization": ["hate speech", "extremism", "online radicalization", "propaganda"],
|
84 |
-
"Mob & Sectarian Violence": ["mob attack", "lynching", "sectarian violence", "hate crimes"],
|
85 |
-
"Counterterrorism & De-Radicalization": ["terrorism", "prevention", "peacebuilding", "rehabilitation"]
|
86 |
},
|
87 |
"Social Inequality & Economic Disparities": {
|
88 |
-
"Class Privilege & Labor Rights": ["classism", "labor rights", "unions", "wage gap"],
|
89 |
-
"Poverty & Economic Justice": ["poverty", "inequality", "economic disparity", "wealth gap"],
|
90 |
-
"Housing & Healthcare": ["housing crisis", "healthcare access", "social safety nets"]
|
91 |
},
|
92 |
"Activism & Advocacy": {
|
93 |
-
"Policy Advocacy & Legal Reforms": ["campaign", "policy change", "legal advocacy"],
|
94 |
-
"Social Media Activism": ["hashtags", "digital activism", "awareness campaign"],
|
95 |
-
"Freedom of Expression & Press": ["press freedom", "censorship", "media rights"]
|
96 |
},
|
97 |
"Systemic Oppression": {
|
98 |
-
"Marginalized Communities": ["minorities", "exclusion", "systemic discrimination"],
|
99 |
-
"Racial & Ethnic Discrimination": ["racism", "xenophobia", "ethnic cleansing", "casteism"],
|
100 |
-
"Institutional Bias": ["institutional racism", "structural oppression", "biased laws"]
|
101 |
},
|
102 |
"Intersectionality": {
|
103 |
-
"Multiple Oppressions": ["overlapping struggles", "intersecting identities", "double discrimination"],
|
104 |
-
"Women & Marginalized Identities": ["feminism", "queer feminism", "minority women"],
|
105 |
-
"Global Solidarity Movements": ["transnational activism", "cross-movement solidarity"]
|
106 |
-
},
|
107 |
-
"Call to Action": {
|
108 |
-
"Petitions & Direct Action": ["sign petition", "protest", "boycott"],
|
109 |
-
"Fundraising & Support": ["donate", "crowdfunding", "aid support"],
|
110 |
-
"Policy & Legislative Action": ["policy change", "demand action", "write to lawmakers"]
|
111 |
-
},
|
112 |
-
"Empowerment & Resistance": {
|
113 |
-
"Grassroots Organizing": ["community empowerment", "leadership training"],
|
114 |
-
"Revolutionary Movements": ["resistance", "revolt", "revolutionary change"],
|
115 |
-
"Inspiration & Motivational Messaging": ["hope", "courage", "overcoming struggles"]
|
116 |
-
},
|
117 |
-
"Climate Justice": {
|
118 |
-
"Indigenous Environmental Activism": ["land rights", "indigenous climate leadership"],
|
119 |
-
"Corporate Accountability": ["big oil", "corporate greed", "environmental negligence"],
|
120 |
-
"Sustainable Development": ["eco-friendly", "renewable energy", "circular economy"]
|
121 |
-
},
|
122 |
-
"Human Rights Advocacy": {
|
123 |
-
"Criminal Justice Reform": ["police brutality", "wrongful convictions", "prison reform"],
|
124 |
-
"Workplace Discrimination & Labor Rights": ["workplace bias", "equal pay", "unions"],
|
125 |
-
"International Human Rights": ["humanitarian law", "UN declarations", "international treaties"]
|
126 |
}
|
127 |
}
|
128 |
|
@@ -245,7 +226,7 @@ def create_docx_from_data(extracted_data):
|
|
245 |
if key in ["Tone", "Hashtags"]:
|
246 |
value = ", ".join(value) if isinstance(value, list) else value
|
247 |
elif key == "Frames" and isinstance(value, dict):
|
248 |
-
frame_text = "\n".join([f" {category}: {', '.join(frames)}" for category, frames in value.items() if frames])
|
249 |
value = f"\n{frame_text}" if frame_text else "N/A"
|
250 |
|
251 |
doc.add_paragraph(f"**{key}:** {value}")
|
|
|
49 |
|
50 |
# Frame categories for fallback method
|
51 |
|
52 |
+
# AI-Expanded Frame Categories for More Precise Categorization
|
53 |
frame_categories = {
|
54 |
"Human Rights & Justice": {
|
55 |
+
"Legal Rights & Reforms": ["law", "justice", "legal", "reforms", "legislation", "human rights", "court", "trial", "lawsuit", "due process", "legal aid", "constitutional rights", "judiciary", "legal defense"],
|
56 |
+
"Humanitarian Issues": ["humanitarian", "aid", "refugees", "asylum", "crisis response", "displacement", "famine", "disaster relief", "war victims", "NGO support", "humanitarian corridors", "food security"],
|
57 |
+
"Civil Liberties": ["freedom", "expression", "privacy", "rights violations", "censorship", "surveillance", "press freedom", "free speech", "whistleblower", "state repression", "thought control"]
|
58 |
},
|
59 |
"Political & State Accountability": {
|
60 |
+
"Corruption & Governance": ["corruption", "government", "policy", "accountability", "transparency", "bribery", "misuse of power", "scandal", "nepotism", "tax fraud", "political ethics"],
|
61 |
+
"Political Oppression": ["authoritarianism", "censorship", "state control", "dissent", "crackdown", "political prisoners", "martial law", "dictatorship", "state violence", "militarization"],
|
62 |
+
"Elections & Political Representation": ["voting", "elections", "political participation", "democracy", "voter suppression", "fraud", "ballot", "electoral reform", "gerrymandering", "campaign finance reform"]
|
63 |
},
|
64 |
"Gender & Patriarchy": {
|
65 |
+
"Gender-Based Violence": ["violence", "domestic abuse", "sexual harassment", "femicide", "sexual assault", "stalking", "forced marriage", "honor killings", "gender violence", "misogyny"],
|
66 |
+
"Women's Rights & Equality": ["gender equality", "feminism", "reproductive rights", "patriarchy", "pay gap", "maternal health", "women's leadership", "workplace discrimination", "sexism", "gender equity"],
|
67 |
+
"LGBTQ+ Rights": ["queer rights", "LGBTQ+", "gender identity", "trans rights", "homophobia", "pride", "same-sex marriage", "conversion therapy", "non-binary", "gender fluidity", "intersectional LGBTQ+ activism"]
|
68 |
},
|
69 |
"Religious Freedom & Persecution": {
|
70 |
+
"Religious Discrimination": ["persecution", "intolerance", "sectarianism", "faith-based violence", "hate crime", "blasphemy", "religious hate speech", "atheist rights"],
|
71 |
+
"Religious Minorities' Rights": ["minorities", "blasphemy laws", "religious freedom", "forced conversion", "places of worship", "religious refugee", "interfaith dialogue", "church-state separation"]
|
72 |
},
|
73 |
"Grassroots Mobilization": {
|
74 |
+
"Community Activism": ["activism", "grassroots", "volunteering", "local organizing", "community engagement", "mutual aid", "citizen action", "door-to-door organizing"],
|
75 |
+
"Protests & Demonstrations": ["march", "strike", "rally", "sit-in", "boycott", "mass mobilization", "civil disobedience", "public gathering", "direct action", "peaceful protest"],
|
76 |
+
"Coalition Building": ["solidarity", "collaboration", "alliances", "mutual aid", "networking", "joint statement", "collective movement", "intersectional activism"]
|
77 |
},
|
78 |
"Environmental Crisis & Activism": {
|
79 |
+
"Climate Change Awareness": ["climate crisis", "global warming", "carbon emissions", "fossil fuels", "sea level rise", "heatwaves", "melting ice caps", "climate denialism", "climate resilience"],
|
80 |
+
"Conservation & Sustainability": ["deforestation", "wildlife protection", "biodiversity", "reforestation", "green energy", "sustainable agriculture", "plastic pollution", "ecological preservation"],
|
81 |
+
"Environmental Justice": ["pollution", "water crisis", "land rights", "indigenous rights", "eco-activism", "environmental racism", "waste management", "toxic exposure", "corporate environmental responsibility"]
|
82 |
},
|
83 |
"Anti-Extremism & Anti-Violence": {
|
84 |
+
"Hate Speech & Radicalization": ["hate speech", "extremism", "online radicalization", "propaganda", "far-right groups", "hate groups", "online disinformation", "terrorist recruitment"],
|
85 |
+
"Mob & Sectarian Violence": ["mob attack", "lynching", "sectarian violence", "hate crimes", "communal riots", "armed militia", "religious riots", "paramilitary violence"],
|
86 |
+
"Counterterrorism & De-Radicalization": ["terrorism", "prevention", "peacebuilding", "rehabilitation", "extremist ideology", "security policy", "deradicalization programs"]
|
87 |
},
|
88 |
"Social Inequality & Economic Disparities": {
|
89 |
+
"Class Privilege & Labor Rights": ["classism", "labor rights", "unions", "wage gap", "worker exploitation", "fair wages", "labor strikes", "union busting", "gig economy exploitation"],
|
90 |
+
"Poverty & Economic Justice": ["poverty", "inequality", "economic disparity", "wealth gap", "unemployment", "food insecurity", "universal basic income", "wealth redistribution"],
|
91 |
+
"Housing & Healthcare": ["housing crisis", "healthcare access", "social safety nets", "homelessness", "medicaid", "affordable housing", "public health"]
|
92 |
},
|
93 |
"Activism & Advocacy": {
|
94 |
+
"Policy Advocacy & Legal Reforms": ["campaign", "policy change", "legal advocacy", "legislative reform", "policy shift", "lobbying", "justice reform"],
|
95 |
+
"Social Media Activism": ["hashtags", "digital activism", "awareness campaign", "viral movement", "online protest", "cyber activism", "influencer advocacy"],
|
96 |
+
"Freedom of Expression & Press": ["press freedom", "censorship", "media rights", "journalist safety", "fake news", "whistleblowing", "independent media"]
|
97 |
},
|
98 |
"Systemic Oppression": {
|
99 |
+
"Marginalized Communities": ["minorities", "exclusion", "systemic discrimination", "oppression", "intersectionality", "social marginalization"],
|
100 |
+
"Racial & Ethnic Discrimination": ["racism", "xenophobia", "ethnic cleansing", "casteism", "racial profiling", "hate speech", "anti-Blackness"],
|
101 |
+
"Institutional Bias": ["institutional racism", "structural oppression", "biased laws", "discriminatory policies", "racial justice"]
|
102 |
},
|
103 |
"Intersectionality": {
|
104 |
+
"Multiple Oppressions": ["overlapping struggles", "intersecting identities", "double discrimination", "marginalization", "intersectional struggles"],
|
105 |
+
"Women & Marginalized Identities": ["feminism", "queer feminism", "minority women", "disabled women", "indigenous women"],
|
106 |
+
"Global Solidarity Movements": ["transnational activism", "cross-movement solidarity", "international justice", "global human rights"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
108 |
}
|
109 |
|
|
|
226 |
if key in ["Tone", "Hashtags"]:
|
227 |
value = ", ".join(value) if isinstance(value, list) else value
|
228 |
elif key == "Frames" and isinstance(value, dict):
|
229 |
+
frame_text = "\n".join([f" {category}: {', '.join([' → '.join(frame) for frame in frames])}" for category, frames in value.items() if frames])
|
230 |
value = f"\n{frame_text}" if frame_text else "N/A"
|
231 |
|
232 |
doc.add_paragraph(f"**{key}:** {value}")
|