tweet_eval / app.py
elozano's picture
App updated
5dcec38
import streamlit as st
from tweet_pipeline import TweetPipeline
EMOTION_EMOJIS = {"Anger": "😑", "Joy": "πŸ˜‚", "Optimism": "πŸ˜‰", "Sadness": "😒"}
OFFENSIVE_EMOJIS = {"Offensive": "😈", "Non-Offensive": "πŸ˜‡"}
SENTIMENT_EMOJIS = {"Negative": "❌", "Neutral": "πŸ€·β€β™‚οΈ", "Positive": "βœ…"}
tweet_eval = TweetPipeline()
st.title("🐦 Tweet Evaluator")
input_text = st.text_input("")
button = st.button("Evaluate!")
if button and input_text != "":
with st.spinner("Evaluating tweet..."):
prediction = tweet_eval(input_text)
st.success("Tweet successfully evaluated!")
st.markdown(
f"{EMOTION_EMOJIS[prediction['emotion']]} **Emotion:** {prediction['emotion']}"
)
st.markdown(
f"{OFFENSIVE_EMOJIS[prediction['offensive']]} **Offensive:** {'Yes' if prediction['offensive'] == 'Offensive' else 'No'}"
)
st.markdown(
f"{SENTIMENT_EMOJIS[prediction['sentiment']]} **Sentiment:** {prediction['sentiment']}"
)
elif button and not input_text:
st.warning("Please, introduce a tweet to eval.")