some fixed & emoji
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ text = st.text_area('Submit your stories', '''Words and symbols are meant to be
|
|
13 |
if text != 'Words and symbols are meant to be here':
|
14 |
# emotions
|
15 |
emotion_result = get_emotion(text)
|
16 |
-
st.write(f"Overall emotion of your story: {emotion_result[0]['label']}")
|
17 |
joy, sad = 0, 0
|
18 |
for emo in emotion_result:
|
19 |
if emo['label'] == 'joy':
|
@@ -24,20 +24,24 @@ if text != 'Words and symbols are meant to be here':
|
|
24 |
joy = emo['score']
|
25 |
elif emo['label'] == 'sadness':
|
26 |
sad = emo['score']
|
27 |
-
st.write(f"Joy level: {joy:.2f}
|
|
|
28 |
|
29 |
# emotional arcs
|
30 |
sents = sent_tokenize(text)
|
31 |
emo_arc = []
|
32 |
for sent in sents:
|
|
|
33 |
emo_arc.append(emotion_result[0]['label'])
|
34 |
sentiment_arc_eval = get_sentiment_arc_evaluation(emo_arc)
|
35 |
-
st.write(f"Emotional arc of your story: {' - '.join(emo_arc)}")
|
36 |
-
st.write(sentiment_arc_eval)
|
37 |
|
38 |
# simple statistics
|
39 |
words = word_tokenize(text)
|
40 |
if len(words) < 5:
|
41 |
st.write("Isn't your story a bit too short?")
|
42 |
rep_ratio = get_repetitions(words)
|
43 |
-
|
|
|
|
|
|
13 |
if text != 'Words and symbols are meant to be here':
|
14 |
# emotions
|
15 |
emotion_result = get_emotion(text)
|
16 |
+
st.write(f"๐ฎ Overall emotion of your story: {emotion_result[0]['label']}")
|
17 |
joy, sad = 0, 0
|
18 |
for emo in emotion_result:
|
19 |
if emo['label'] == 'joy':
|
|
|
24 |
joy = emo['score']
|
25 |
elif emo['label'] == 'sadness':
|
26 |
sad = emo['score']
|
27 |
+
st.write(f"๐ธ Joy level: {joy:.2f}%")
|
28 |
+
st.write(f"๐ฟ Sadness level: {sad:.2f}%")
|
29 |
|
30 |
# emotional arcs
|
31 |
sents = sent_tokenize(text)
|
32 |
emo_arc = []
|
33 |
for sent in sents:
|
34 |
+
emotion_result = get_emotion(sent)
|
35 |
emo_arc.append(emotion_result[0]['label'])
|
36 |
sentiment_arc_eval = get_sentiment_arc_evaluation(emo_arc)
|
37 |
+
st.write(f"๐ Emotional arc of your story: {' - '.join(emo_arc)}")
|
38 |
+
st.write('๐ ' + sentiment_arc_eval)
|
39 |
|
40 |
# simple statistics
|
41 |
words = word_tokenize(text)
|
42 |
if len(words) < 5:
|
43 |
st.write("Isn't your story a bit too short?")
|
44 |
rep_ratio = get_repetitions(words)
|
45 |
+
if rep_ratio < 0.7:
|
46 |
+
st.write("Seems too repetitive!")
|
47 |
+
st.write(f"Repetition ratio: {rep_ratio:.2f}")
|