Spaces:
Runtime error
Runtime error
| 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.") | |