yashkens commited on
Commit
f6d175c
โ€ข
1 Parent(s): 057e447

some fixed & emoji

Browse files
Files changed (1) hide show
  1. app.py +9 -5
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}%\nSadness level: {sad:.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
- st.write(f"Repetition ratio: {rep_ratio}")
 
 
 
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}")