Spaces:
Running
Running
Krish Patel
commited on
Commit
Β·
21bc2b4
1
Parent(s):
15e4be7
try4
Browse files
app.py
CHANGED
@@ -144,6 +144,9 @@ def main():
|
|
144 |
gemini_result = analyze_content_gemini(gemini_model, news_text)
|
145 |
|
146 |
# First show the high-level metrics in columns
|
|
|
|
|
|
|
147 |
col1, col2, col3 = st.columns(3)
|
148 |
|
149 |
with col1:
|
@@ -163,83 +166,51 @@ def main():
|
|
163 |
st.metric("Prediction", gemini_pred)
|
164 |
st.metric("Confidence", f"{gemini_conf}%")
|
165 |
|
166 |
-
# Single expander for all
|
167 |
-
with st.expander("
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
|
|
|
|
|
|
203 |
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
st.write("Emotional Triggers:", ", ".join(sentiment.get('emotional_triggers', ['N/A'])))
|
208 |
-
|
209 |
-
# Entity Recognition
|
210 |
-
st.subheader("π Entity Recognition")
|
211 |
-
entities = gemini_result.get('entity_recognition', {})
|
212 |
-
st.write(f"Source Credibility: {entities.get('source_credibility', 'N/A')}")
|
213 |
-
st.write("People:", ", ".join(entities.get('people', ['N/A'])))
|
214 |
-
st.write("Organizations:", ", ".join(entities.get('organizations', ['N/A'])))
|
215 |
-
st.write("Locations:", ", ".join(entities.get('locations', ['N/A'])))
|
216 |
-
st.write("Dates:", ", ".join(entities.get('dates', ['N/A'])))
|
217 |
-
st.write("Statistics:", ", ".join(entities.get('statistics', ['N/A'])))
|
218 |
-
|
219 |
-
# Context
|
220 |
-
st.subheader("π° Context")
|
221 |
-
context = gemini_result.get('context', {})
|
222 |
-
st.write("Main Narrative:", context.get('main_narrative', 'N/A'))
|
223 |
-
st.write("Supporting Elements:", ", ".join(context.get('supporting_elements', ['N/A'])))
|
224 |
-
st.write("Key Claims:", ", ".join(context.get('key_claims', ['N/A'])))
|
225 |
-
st.write("Narrative Structure:", context.get('narrative_structure', 'N/A'))
|
226 |
-
|
227 |
-
# Fact Checking
|
228 |
-
st.subheader("βοΈ Fact Checking")
|
229 |
-
fact_check = gemini_result.get('fact_checking', {})
|
230 |
-
st.write("Verifiable Claims:")
|
231 |
-
for claim in fact_check.get('verifiable_claims', ['N/A']):
|
232 |
-
st.write(f"β’ {claim}")
|
233 |
-
st.write(f"Evidence Present: {fact_check.get('evidence_present', 'N/A')}")
|
234 |
-
st.write(f"Fact Check Score: {fact_check.get('fact_check_score', 'N/A')}/100")
|
235 |
-
|
236 |
-
# Analysis Reasoning
|
237 |
-
st.subheader("π Analysis Reasoning")
|
238 |
-
for point in gemini_result.get('gemini_analysis', {}).get('reasoning', ['N/A']):
|
239 |
-
st.write(f"β’ {point}")
|
240 |
-
|
241 |
-
except Exception as e:
|
242 |
-
st.error("Error processing Gemini analysis results")
|
243 |
|
244 |
|
245 |
with st.expander("Named Entities"):
|
|
|
144 |
gemini_result = analyze_content_gemini(gemini_model, news_text)
|
145 |
|
146 |
# First show the high-level metrics in columns
|
147 |
+
# In the main() function:
|
148 |
+
|
149 |
+
# Display metrics in columns
|
150 |
col1, col2, col3 = st.columns(3)
|
151 |
|
152 |
with col1:
|
|
|
166 |
st.metric("Prediction", gemini_pred)
|
167 |
st.metric("Confidence", f"{gemini_conf}%")
|
168 |
|
169 |
+
# Single expander for all analysis details
|
170 |
+
with st.expander("Detailed Analysis"):
|
171 |
+
try:
|
172 |
+
# Text Classification
|
173 |
+
st.subheader("π Text Classification")
|
174 |
+
text_class = gemini_result.get('text_classification', {})
|
175 |
+
st.write(f"Category: {text_class.get('category', 'N/A')}")
|
176 |
+
st.write(f"Writing Style: {text_class.get('writing_style', 'N/A')}")
|
177 |
+
st.write(f"Target Audience: {text_class.get('target_audience', 'N/A')}")
|
178 |
+
st.write(f"Content Type: {text_class.get('content_type', 'N/A')}")
|
179 |
+
|
180 |
+
# Sentiment Analysis
|
181 |
+
st.subheader("π Sentiment Analysis")
|
182 |
+
sentiment = gemini_result.get('sentiment_analysis', {})
|
183 |
+
st.write(f"Primary Emotion: {sentiment.get('primary_emotion', 'N/A')}")
|
184 |
+
st.write(f"Emotional Intensity: {sentiment.get('emotional_intensity', 'N/A')}/10")
|
185 |
+
st.write(f"Sensationalism Level: {sentiment.get('sensationalism_level', 'N/A')}")
|
186 |
+
st.write("Bias Indicators:", ", ".join(sentiment.get('bias_indicators', ['N/A'])))
|
187 |
+
|
188 |
+
# Entity Recognition
|
189 |
+
st.subheader("π Entity Recognition")
|
190 |
+
entities = gemini_result.get('entity_recognition', {})
|
191 |
+
st.write(f"Source Credibility: {entities.get('source_credibility', 'N/A')}")
|
192 |
+
st.write("People:", ", ".join(entities.get('people', ['N/A'])))
|
193 |
+
st.write("Organizations:", ", ".join(entities.get('organizations', ['N/A'])))
|
194 |
+
|
195 |
+
# Named Entities from spaCy
|
196 |
+
st.subheader("π·οΈ Named Entities")
|
197 |
+
entities = extract_entities(news_text, nlp)
|
198 |
+
df = pd.DataFrame(entities, columns=["Entity", "Type"])
|
199 |
+
st.dataframe(df)
|
200 |
+
|
201 |
+
# Knowledge Graph Visualization
|
202 |
+
st.subheader("πΈοΈ Knowledge Graph")
|
203 |
+
fig = generate_knowledge_graph_viz(news_text, nlp, tokenizer, model)
|
204 |
+
st.plotly_chart(fig, use_container_width=True)
|
205 |
+
|
206 |
+
# Analysis Reasoning
|
207 |
+
st.subheader("π Analysis Reasoning")
|
208 |
+
for point in gemini_result.get('gemini_analysis', {}).get('reasoning', ['N/A']):
|
209 |
+
st.write(f"β’ {point}")
|
210 |
|
211 |
+
except Exception as e:
|
212 |
+
st.error("Error processing analysis results")
|
213 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
|
216 |
with st.expander("Named Entities"):
|