StoryTime / app.py
yashkens's picture
add emotional arc analysis
107d15e
raw
history blame
743 Bytes
import streamlit as st
# from emoji import get_emoji
from emotions import get_emotion, get_sentiment_arc_evaluation
from nltk.tokenize import sent_tokenize
nltk.download('punkt')
st.title("I don't even know what this is yet")
name = st.text_input('Who are you?', 'Right, who am I?')
text = st.text_area('Submit your stories', '''Words and symbols are meant to be here''')
emotion_result = get_emotion(text)
st.write(f"Overall emotion of your story: {emotion_result[0]['label']}")
sents = sent_tokenize(text)
emo_arc = []
for sent in sents:
emo_arc.append(emotion_result[0]['label'])
sentiment_arc_eval = get_sentiment_arc_evaluation(emo_arc)
st.write(f"Emotional arc of your story: {' - '.join(emo_arc)}")
st.write(sentiment_arc_eval)