Update app.py
Browse files
app.py
CHANGED
@@ -24,11 +24,15 @@ def display_sentiment_results(annotations):
|
|
24 |
score = annotations.document_sentiment.score
|
25 |
magnitude = annotations.document_sentiment.magnitude
|
26 |
|
|
|
27 |
for index, sentence in enumerate(annotations.sentences):
|
28 |
sentence_sentiment = sentence.sentiment.score
|
29 |
-
|
|
|
|
|
30 |
|
31 |
-
|
|
|
32 |
|
33 |
# Main function to run the app
|
34 |
def main():
|
|
|
24 |
score = annotations.document_sentiment.score
|
25 |
magnitude = annotations.document_sentiment.magnitude
|
26 |
|
27 |
+
# Loop through the sentences and display sentiment score with 2 decimal places
|
28 |
for index, sentence in enumerate(annotations.sentences):
|
29 |
sentence_sentiment = sentence.sentiment.score
|
30 |
+
sentence_text = sentence.text.content # Get the text of the sentence
|
31 |
+
st.write(f"Sentence {index} sentiment score: {sentence_sentiment:.2f}; magnitude: {magnitude:.2f}")
|
32 |
+
st.write(f"Text from Sentence {index}: {sentence_text}") # Display the text of the sentence
|
33 |
|
34 |
+
# Display overall sentiment with 2 decimal places
|
35 |
+
st.write(f"Overall Sentiment: score of {score:.2f} with magnitude of {magnitude:.2f}")
|
36 |
|
37 |
# Main function to run the app
|
38 |
def main():
|