Spaces:
Sleeping
Sleeping
Ryan
commited on
Commit
·
4973fc0
1
Parent(s):
4069671
update
Browse files
visualization/roberta_visualizer.py
CHANGED
@@ -63,24 +63,13 @@ def create_sentiment_visualization(analysis_results):
|
|
63 |
|
64 |
for model_name in models:
|
65 |
if model_name in sa_data:
|
66 |
-
model_result = sa_data
|
67 |
if model_result is not None:
|
68 |
score = model_result.get("sentiment_score", 0)
|
69 |
label = model_result.get("label", "neutral").capitalize()
|
70 |
else:
|
71 |
score = 0
|
72 |
label = "Neutral"
|
73 |
-
for model_name in models:
|
74 |
-
if model_name in sa_data:
|
75 |
-
model_result = sa_data[model_name]
|
76 |
-
if model_result is not None:
|
77 |
-
# Now safely access model_result
|
78 |
-
score = model_result.get("sentiment_score", 0)
|
79 |
-
label = model_result.get("label", "neutral").capitalize()
|
80 |
-
else:
|
81 |
-
# Provide defaults when model_result is None
|
82 |
-
score = 0
|
83 |
-
label = "Neutral"
|
84 |
|
85 |
# Set color based on sentiment
|
86 |
if label.lower() == "positive":
|
@@ -103,8 +92,10 @@ def create_sentiment_visualization(analysis_results):
|
|
103 |
model_scores = []
|
104 |
for model_name in models:
|
105 |
if model_name in sa_data:
|
106 |
-
|
107 |
-
|
|
|
|
|
108 |
|
109 |
if len(model_scores) >= 2:
|
110 |
gauge_html = "<div style='margin: 20px 0; padding: 15px; background-color: #f8f9fa; border-radius: 5px;'>"
|
@@ -177,8 +168,12 @@ def create_sentiment_visualization(analysis_results):
|
|
177 |
model_sentences = {}
|
178 |
|
179 |
for model_name in models:
|
180 |
-
if model_name in sa_data
|
181 |
-
|
|
|
|
|
|
|
|
|
182 |
|
183 |
if model_sentences and any(len(sentences) > 0 for sentences in model_sentences.values()):
|
184 |
output_components.append(gr.Markdown("### Sentence-Level Sentiment Analysis"))
|
|
|
63 |
|
64 |
for model_name in models:
|
65 |
if model_name in sa_data:
|
66 |
+
model_result = sa_data.get(model_name)
|
67 |
if model_result is not None:
|
68 |
score = model_result.get("sentiment_score", 0)
|
69 |
label = model_result.get("label", "neutral").capitalize()
|
70 |
else:
|
71 |
score = 0
|
72 |
label = "Neutral"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Set color based on sentiment
|
75 |
if label.lower() == "positive":
|
|
|
92 |
model_scores = []
|
93 |
for model_name in models:
|
94 |
if model_name in sa_data:
|
95 |
+
model_result = sa_data.get(model_name)
|
96 |
+
if model_result is not None:
|
97 |
+
score = model_result.get("sentiment_score", 0)
|
98 |
+
model_scores.append((model_name, score))
|
99 |
|
100 |
if len(model_scores) >= 2:
|
101 |
gauge_html = "<div style='margin: 20px 0; padding: 15px; background-color: #f8f9fa; border-radius: 5px;'>"
|
|
|
168 |
model_sentences = {}
|
169 |
|
170 |
for model_name in models:
|
171 |
+
if model_name in sa_data:
|
172 |
+
model_result = sa_data.get(model_name)
|
173 |
+
if model_result is not None and "sentence_scores" in model_result:
|
174 |
+
sentence_scores = model_result.get("sentence_scores")
|
175 |
+
if sentence_scores:
|
176 |
+
model_sentences[model_name] = sentence_scores
|
177 |
|
178 |
if model_sentences and any(len(sentences) > 0 for sentences in model_sentences.values()):
|
179 |
output_components.append(gr.Markdown("### Sentence-Level Sentiment Analysis"))
|