Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -116,6 +116,7 @@ def analyze_article(text: str) -> dict:
|
|
| 116 |
"subjectivity_score": subjectivity_score,
|
| 117 |
"reading_ease": reading_ease,
|
| 118 |
"primary_tone": primary_tone,
|
|
|
|
| 119 |
"tone_scores": tone_scores,
|
| 120 |
"keywords": extracted_keywords,
|
| 121 |
"entities": extracted_entities,
|
|
@@ -147,7 +148,7 @@ def _create_sentiment_gauge(score: float, title: str) -> go.Figure:
|
|
| 147 |
|
| 148 |
def _create_comparison_radar_chart(results_a: dict, results_b: dict) -> go.Figure:
|
| 149 |
"""Generates an overlapping radar chart to compare emotions."""
|
| 150 |
-
categories = list(set(list(results_a["tone_scores"].keys()) + list(results_b["tone_scores"].keys())))
|
| 151 |
|
| 152 |
val_a = [results_a["tone_scores"].get(c, 0) for c in categories]
|
| 153 |
val_b = [results_b["tone_scores"].get(c, 0) for c in categories]
|
|
@@ -224,7 +225,7 @@ def check_contradiction(text_a: str, text_b: str) -> dict:
|
|
| 224 |
premise = text_a[:400]
|
| 225 |
hypothesis = text_b[:400]
|
| 226 |
|
| 227 |
-
nli_input =
|
| 228 |
result = models["nli"](nli_input)[0]
|
| 229 |
|
| 230 |
return {"relationship": result["label"], "confidence": result["score"]}
|
|
@@ -283,7 +284,7 @@ if st.session_state.results_a and st.session_state.results_b:
|
|
| 283 |
# Display Contradictions
|
| 284 |
nli_result = st.session_state.nli_result
|
| 285 |
if nli_result:
|
| 286 |
-
if nli_result["relationship"] == "CONTRADICTION":
|
| 287 |
st.error(f"**NARRATIVE CONTRADICTION** (Confidence: {nli_result['confidence']:.2f}) - These sources are disputing each other's facts.")
|
| 288 |
elif nli_result["relationship"] == "ENTAILMENT":
|
| 289 |
st.success(f"**NARRATIVE ALIGNMENT** (Confidence: {nli_result['confidence']:.2f}) - These sources agree on the core premise.")
|
|
|
|
| 116 |
"subjectivity_score": subjectivity_score,
|
| 117 |
"reading_ease": reading_ease,
|
| 118 |
"primary_tone": primary_tone,
|
| 119 |
+
"primary_theme": primary_theme,
|
| 120 |
"tone_scores": tone_scores,
|
| 121 |
"keywords": extracted_keywords,
|
| 122 |
"entities": extracted_entities,
|
|
|
|
| 148 |
|
| 149 |
def _create_comparison_radar_chart(results_a: dict, results_b: dict) -> go.Figure:
|
| 150 |
"""Generates an overlapping radar chart to compare emotions."""
|
| 151 |
+
categories = sorted(list(set(list(results_a["tone_scores"].keys()) + list(results_b["tone_scores"].keys()))))
|
| 152 |
|
| 153 |
val_a = [results_a["tone_scores"].get(c, 0) for c in categories]
|
| 154 |
val_b = [results_b["tone_scores"].get(c, 0) for c in categories]
|
|
|
|
| 225 |
premise = text_a[:400]
|
| 226 |
hypothesis = text_b[:400]
|
| 227 |
|
| 228 |
+
nli_input = {"text": premise, "text_pair": hypothesis}
|
| 229 |
result = models["nli"](nli_input)[0]
|
| 230 |
|
| 231 |
return {"relationship": result["label"], "confidence": result["score"]}
|
|
|
|
| 284 |
# Display Contradictions
|
| 285 |
nli_result = st.session_state.nli_result
|
| 286 |
if nli_result:
|
| 287 |
+
if nli_result["relationship"].upper() == "CONTRADICTION":
|
| 288 |
st.error(f"**NARRATIVE CONTRADICTION** (Confidence: {nli_result['confidence']:.2f}) - These sources are disputing each other's facts.")
|
| 289 |
elif nli_result["relationship"] == "ENTAILMENT":
|
| 290 |
st.success(f"**NARRATIVE ALIGNMENT** (Confidence: {nli_result['confidence']:.2f}) - These sources agree on the core premise.")
|