Update app.py
Browse files
app.py
CHANGED
@@ -285,18 +285,21 @@ class SpeechAnalyzer:
|
|
285 |
|
286 |
@st.cache_data
|
287 |
def process_all_analyses(text, _analyzer):
|
288 |
-
segments =
|
289 |
num_segments = len(segments)
|
290 |
segment_labels = [f"{i+1}" for i in range(num_segments)]
|
291 |
|
292 |
-
sentiment_scores, basic_emotions =
|
293 |
moral_trajectories = {foundation: [] for foundation in ['care', 'fairness', 'loyalty', 'authority', 'sanctity']}
|
294 |
for segment in segments:
|
295 |
-
moral_scores =
|
296 |
for foundation in moral_trajectories.keys():
|
297 |
moral_trajectories[foundation].append(moral_scores[foundation])
|
298 |
|
299 |
return segments, segment_labels, sentiment_scores, basic_emotions, moral_trajectories
|
|
|
|
|
|
|
300 |
def main():
|
301 |
st.title("🗣️ Political Text Analysis Toolkit")
|
302 |
|
|
|
285 |
|
286 |
@st.cache_data
|
287 |
def process_all_analyses(text, _analyzer):
|
288 |
+
segments = _analyzer.split_text(text, max_length=512)
|
289 |
num_segments = len(segments)
|
290 |
segment_labels = [f"{i+1}" for i in range(num_segments)]
|
291 |
|
292 |
+
sentiment_scores, basic_emotions = _analyzer.analyze_emotional_trajectory(text)
|
293 |
moral_trajectories = {foundation: [] for foundation in ['care', 'fairness', 'loyalty', 'authority', 'sanctity']}
|
294 |
for segment in segments:
|
295 |
+
moral_scores = _analyzer.analyze_moral_foundations(segment)
|
296 |
for foundation in moral_trajectories.keys():
|
297 |
moral_trajectories[foundation].append(moral_scores[foundation])
|
298 |
|
299 |
return segments, segment_labels, sentiment_scores, basic_emotions, moral_trajectories
|
300 |
+
|
301 |
+
|
302 |
+
return segments, segment_labels, sentiment_scores, basic_emotions, moral_trajectories
|
303 |
def main():
|
304 |
st.title("🗣️ Political Text Analysis Toolkit")
|
305 |
|