Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,7 +48,7 @@ def analyze_article(text: str) -> dict:
|
|
| 48 |
Keys to return:
|
| 49 |
"sentiment_score": A float between -1.0 (highly negative) and 1.0 (highly positive).
|
| 50 |
"primary_tone": The single dominant emotion.
|
| 51 |
-
"
|
| 52 |
"tone_scores": A dictionary scoring THESE EXACT 6 EMOTIONS from 0.0 to 1.0: {{"anger": 0.0, "fear": 0.0, "joy": 0.0, "sadness": 0.0, "surprise": 0.0, "trust": 0.0}}.
|
| 53 |
"framing_words": A list of dictionaries containing the 5 to 8 most emotionally charged or biased words, and the specific emotion they evoke. Format: [{{"word": "draconian", "emotion": "fear"}}, {{"word": "titans", "emotion": "awe"}}].
|
| 54 |
"subjectivity_score": A float between 0.0 (completely objective/factual) and 1.0 (highly opinionated/subjective).
|
|
@@ -86,7 +86,7 @@ def analyze_article(text: str) -> dict:
|
|
| 86 |
return {
|
| 87 |
"sentiment_score": llm_data.get("sentiment_score", 0.0),
|
| 88 |
"primary_tone": llm_data.get("primary_tone", "neutral"),
|
| 89 |
-
"
|
| 90 |
"tone_scores": standard_tones,
|
| 91 |
"framing_words": llm_data.get("framing_words", []),
|
| 92 |
"subjectivity_score": llm_data.get("subjectivity_score", 0.0),
|
|
@@ -395,7 +395,7 @@ if st.session_state.results_a and st.session_state.results_b:
|
|
| 395 |
m3, m4 = st.columns(2)
|
| 396 |
m1.metric("Subjectivity", f"{r_a['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")
|
| 397 |
m2.metric("Primary Emotion", str(r_a['primary_tone']).title())
|
| 398 |
-
m3.metric("
|
| 399 |
m4.metric("Reading Ease", f"{r_a['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")
|
| 400 |
|
| 401 |
st.plotly_chart(_create_sentiment_gauge(r_a["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_a")
|
|
@@ -412,7 +412,7 @@ if st.session_state.results_a and st.session_state.results_b:
|
|
| 412 |
m3, m4 = st.columns(2)
|
| 413 |
m1.metric("Subjectivity", f"{r_b['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")
|
| 414 |
m2.metric("Primary Emotion", str(r_b['primary_tone']).title())
|
| 415 |
-
m3.metric("
|
| 416 |
m4.metric("Reading Ease", f"{r_b['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")
|
| 417 |
|
| 418 |
st.plotly_chart(_create_sentiment_gauge(r_b["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_b")
|
|
|
|
| 48 |
Keys to return:
|
| 49 |
"sentiment_score": A float between -1.0 (highly negative) and 1.0 (highly positive).
|
| 50 |
"primary_tone": The single dominant emotion.
|
| 51 |
+
"primary_theme": Choose ONE like: ["economic consequences", "moral and ethical fairness", "legal and bureaucratic", "public safety and health"].
|
| 52 |
"tone_scores": A dictionary scoring THESE EXACT 6 EMOTIONS from 0.0 to 1.0: {{"anger": 0.0, "fear": 0.0, "joy": 0.0, "sadness": 0.0, "surprise": 0.0, "trust": 0.0}}.
|
| 53 |
"framing_words": A list of dictionaries containing the 5 to 8 most emotionally charged or biased words, and the specific emotion they evoke. Format: [{{"word": "draconian", "emotion": "fear"}}, {{"word": "titans", "emotion": "awe"}}].
|
| 54 |
"subjectivity_score": A float between 0.0 (completely objective/factual) and 1.0 (highly opinionated/subjective).
|
|
|
|
| 86 |
return {
|
| 87 |
"sentiment_score": llm_data.get("sentiment_score", 0.0),
|
| 88 |
"primary_tone": llm_data.get("primary_tone", "neutral"),
|
| 89 |
+
"primary_theme": llm_data.get("primary_theme", "unclear"),
|
| 90 |
"tone_scores": standard_tones,
|
| 91 |
"framing_words": llm_data.get("framing_words", []),
|
| 92 |
"subjectivity_score": llm_data.get("subjectivity_score", 0.0),
|
|
|
|
| 395 |
m3, m4 = st.columns(2)
|
| 396 |
m1.metric("Subjectivity", f"{r_a['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")
|
| 397 |
m2.metric("Primary Emotion", str(r_a['primary_tone']).title())
|
| 398 |
+
m3.metric("Framing Lens", str(r_a['primary_theme']).title())
|
| 399 |
m4.metric("Reading Ease", f"{r_a['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")
|
| 400 |
|
| 401 |
st.plotly_chart(_create_sentiment_gauge(r_a["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_a")
|
|
|
|
| 412 |
m3, m4 = st.columns(2)
|
| 413 |
m1.metric("Subjectivity", f"{r_b['subjectivity_score']:.2f}", help="0 is objective, 1 is highly opinionated.")
|
| 414 |
m2.metric("Primary Emotion", str(r_b['primary_tone']).title())
|
| 415 |
+
m3.metric("Framing Lens", str(r_b['primary_theme']).title())
|
| 416 |
m4.metric("Reading Ease", f"{r_b['reading_ease']:.1f}", help="0-30 is college graduate level, 60-70 is 8th grade.")
|
| 417 |
|
| 418 |
st.plotly_chart(_create_sentiment_gauge(r_b["sentiment_score"], "Sentiment Bias"), use_container_width=True, key="gauge_b")
|