Spaces:
Runtime error
Runtime error
File size: 1,072 Bytes
b5d9d5c 5dcec38 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
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.")
|