yashkens commited on
Commit
904421a
โ€ข
1 Parent(s): e334270

some fixes

Browse files
Files changed (2) hide show
  1. app.py +7 -5
  2. emotions.py +1 -1
app.py CHANGED
@@ -15,7 +15,6 @@ if text != 'Words and symbols are meant to be here':
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
- st.write(f"{emotion_result}")
19
  for emo in emotion_result:
20
  if emo['label'] == 'joy':
21
  if emo['score'] > joy:
@@ -42,7 +41,10 @@ if text != 'Words and symbols are meant to be here':
42
  words = word_tokenize(text)
43
  if len(words) < 5:
44
  st.write("Isn't your story a bit too short?")
45
- rep_ratio = get_repetitions(words)
46
- if rep_ratio < 0.7:
47
- st.write("Seems too repetitive!")
48
- st.write(f"Repetition ratio: {rep_ratio:.2f}")
 
 
 
 
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':
20
  if emo['score'] > joy:
 
41
  words = word_tokenize(text)
42
  if len(words) < 5:
43
  st.write("Isn't your story a bit too short?")
44
+ if len(words) > 0:
45
+ rep_ratio = get_repetitions(words)
46
+ if rep_ratio < 0.7:
47
+ st.write("Seems too repetitive!")
48
+ st.write(f"Repetition ratio: {rep_ratio:.2f}")
49
+ else:
50
+ st.write("A story with no words? Interesting choice.")
emotions.py CHANGED
@@ -24,7 +24,7 @@ def get_sentiment_arc_evaluation(emotions):
24
  if sentiment_arc and sentiment_arc[-1] == sentiment:
25
  continue
26
  sentiment_arc.append(sentiment)
27
- sentiment_arc_str = '\n'.join(sentiment_arc)
28
  if sentiment_arc_str in great_arcs:
29
  return 'What a great plot! Excellent! ๐Ÿ˜'
30
  elif sentiment_arc_str in good_arcs:
 
24
  if sentiment_arc and sentiment_arc[-1] == sentiment:
25
  continue
26
  sentiment_arc.append(sentiment)
27
+ sentiment_arc_str = ' - '.join(sentiment_arc)
28
  if sentiment_arc_str in great_arcs:
29
  return 'What a great plot! Excellent! ๐Ÿ˜'
30
  elif sentiment_arc_str in good_arcs: