Spaces:
Running
Running
Krish Patel
commited on
Commit
Β·
116a946
1
Parent(s):
7a8ca1c
try2
Browse files
app.py
CHANGED
@@ -165,44 +165,63 @@ def main():
|
|
165 |
|
166 |
# Detailed analysis sections
|
167 |
with st.expander("View Detailed Analysis"):
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
# Sentiment Analysis
|
178 |
-
st.subheader("π Sentiment Analysis")
|
179 |
-
sentiment = gemini_result.get('sentiment_analysis', {})
|
180 |
-
st.write(f"Primary Emotion: {sentiment.get('primary_emotion', 'N/A')}")
|
181 |
-
st.write(f"Emotional Intensity: {sentiment.get('emotional_intensity', 'N/A')}/10")
|
182 |
-
st.write(f"Sensationalism Level: {sentiment.get('sensationalism_level', 'N/A')}")
|
183 |
-
|
184 |
-
# Entity Recognition
|
185 |
-
st.subheader("π Entity Recognition")
|
186 |
-
entities = gemini_result.get('entity_recognition', {})
|
187 |
-
st.write(f"Source Credibility: {entities.get('source_credibility', 'N/A')}")
|
188 |
-
st.write("Key People:", ", ".join(entities.get('people', ['N/A'])))
|
189 |
-
st.write("Organizations:", ", ".join(entities.get('organizations', ['N/A'])))
|
190 |
-
|
191 |
-
# Context & Claims
|
192 |
-
st.subheader("π Context & Claims")
|
193 |
-
context = gemini_result.get('context', {})
|
194 |
-
st.write("Main Narrative:", context.get('main_narrative', 'N/A'))
|
195 |
-
st.write("Key Claims:")
|
196 |
-
for claim in gemini_result.get('fact_checking', {}).get('verifiable_claims', ['N/A']):
|
197 |
-
st.write(f"β’ {claim}")
|
198 |
-
|
199 |
-
# Reasoning
|
200 |
-
st.subheader("π Analysis Reasoning")
|
201 |
-
for point in gemini_result.get('gemini_analysis', {}).get('reasoning', ['N/A']):
|
202 |
-
st.write(f"β’ {point}")
|
203 |
|
204 |
-
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
|
207 |
|
208 |
with st.expander("Named Entities"):
|
|
|
165 |
|
166 |
# Detailed analysis sections
|
167 |
with st.expander("View Detailed Analysis"):
|
168 |
+
with st.expander("View Detailed Analysis"):
|
169 |
+
try:
|
170 |
+
# Text Classification
|
171 |
+
st.subheader("π Text Classification")
|
172 |
+
text_class = gemini_result.get('text_classification', {})
|
173 |
+
st.write(f"Category: {text_class.get('category', 'N/A')}")
|
174 |
+
st.write(f"Writing Style: {text_class.get('writing_style', 'N/A')}")
|
175 |
+
st.write(f"Target Audience: {text_class.get('target_audience', 'N/A')}")
|
176 |
+
st.write(f"Content Type: {text_class.get('content_type', 'N/A')}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
+
# Sentiment Analysis
|
179 |
+
st.subheader("π Sentiment Analysis")
|
180 |
+
sentiment = gemini_result.get('sentiment_analysis', {})
|
181 |
+
st.write(f"Primary Emotion: {sentiment.get('primary_emotion', 'N/A')}")
|
182 |
+
st.write(f"Emotional Intensity: {sentiment.get('emotional_intensity', 'N/A')}/10")
|
183 |
+
st.write(f"Sensationalism Level: {sentiment.get('sensationalism_level', 'N/A')}")
|
184 |
+
st.write("Bias Indicators:", ", ".join(sentiment.get('bias_indicators', ['N/A'])))
|
185 |
+
|
186 |
+
tone = sentiment.get('tone', {})
|
187 |
+
st.write(f"Tone Formality: {tone.get('formality', 'N/A')}")
|
188 |
+
st.write(f"Tone Style: {tone.get('style', 'N/A')}")
|
189 |
+
st.write("Emotional Triggers:", ", ".join(sentiment.get('emotional_triggers', ['N/A'])))
|
190 |
+
|
191 |
+
# Entity Recognition
|
192 |
+
st.subheader("π Entity Recognition")
|
193 |
+
entities = gemini_result.get('entity_recognition', {})
|
194 |
+
st.write(f"Source Credibility: {entities.get('source_credibility', 'N/A')}")
|
195 |
+
st.write("People:", ", ".join(entities.get('people', ['N/A'])))
|
196 |
+
st.write("Organizations:", ", ".join(entities.get('organizations', ['N/A'])))
|
197 |
+
st.write("Locations:", ", ".join(entities.get('locations', ['N/A'])))
|
198 |
+
st.write("Dates:", ", ".join(entities.get('dates', ['N/A'])))
|
199 |
+
st.write("Statistics:", ", ".join(entities.get('statistics', ['N/A'])))
|
200 |
+
|
201 |
+
# Context
|
202 |
+
st.subheader("π° Context")
|
203 |
+
context = gemini_result.get('context', {})
|
204 |
+
st.write("Main Narrative:", context.get('main_narrative', 'N/A'))
|
205 |
+
st.write("Supporting Elements:", ", ".join(context.get('supporting_elements', ['N/A'])))
|
206 |
+
st.write("Key Claims:", ", ".join(context.get('key_claims', ['N/A'])))
|
207 |
+
st.write("Narrative Structure:", context.get('narrative_structure', 'N/A'))
|
208 |
+
|
209 |
+
# Fact Checking
|
210 |
+
st.subheader("βοΈ Fact Checking")
|
211 |
+
fact_check = gemini_result.get('fact_checking', {})
|
212 |
+
st.write("Verifiable Claims:")
|
213 |
+
for claim in fact_check.get('verifiable_claims', ['N/A']):
|
214 |
+
st.write(f"β’ {claim}")
|
215 |
+
st.write(f"Evidence Present: {fact_check.get('evidence_present', 'N/A')}")
|
216 |
+
st.write(f"Fact Check Score: {fact_check.get('fact_check_score', 'N/A')}/100")
|
217 |
+
|
218 |
+
# Analysis Reasoning
|
219 |
+
st.subheader("π Analysis Reasoning")
|
220 |
+
for point in gemini_result.get('gemini_analysis', {}).get('reasoning', ['N/A']):
|
221 |
+
st.write(f"β’ {point}")
|
222 |
+
|
223 |
+
except Exception as e:
|
224 |
+
st.error("Error processing Gemini analysis results")
|
225 |
|
226 |
|
227 |
with st.expander("Named Entities"):
|
final.py
CHANGED
@@ -146,7 +146,7 @@ def predict_with_knowledge_graph(text, knowledge_graph, nlp):
|
|
146 |
|
147 |
def analyze_content_gemini(model, text):
|
148 |
"""Analyze content using Gemini model"""
|
149 |
-
prompt = f"""Analyze this news text and return a JSON object with the following structure:
|
150 |
{{
|
151 |
"gemini_analysis": {{
|
152 |
"predicted_classification": "Real or Fake",
|
|
|
146 |
|
147 |
def analyze_content_gemini(model, text):
|
148 |
"""Analyze content using Gemini model"""
|
149 |
+
prompt = f"""Analyze this news text and return a JSON object with the following exact structure:
|
150 |
{{
|
151 |
"gemini_analysis": {{
|
152 |
"predicted_classification": "Real or Fake",
|