Spaces:
Running
Running
from os import write | |
from typing import Sequence | |
import streamlit as st | |
from sentimentorr import sentimentor | |
from demojz import demojj | |
from annotator import ignitor_load,appendor,allll | |
if __name__ == '__main__': | |
st.header("Which sentiment does this text convey? Is it related to work?") | |
st.write("This app tells whether a text can be labeled as related to pecuniary, colleagues, boss, temporal/general aspects of work, or neither of them. It also shows the sentiment of text across 27 different affects + neutral. The goal of this app is to be served as a proof of concept and cross-validator ( data validator ) of the tweets classified by the full-fledged model and to show the code and method that we created and used in our paper. The purpose of this model is to recognize tweets which are related to work from within large corpora of data, to see how their sentiment differs from the rest of the tweets. The FN of the model is high to prevent labeling tweets that are not related to work, as long as the sentiment of labeled tweets is not systematically different than the FN tweets, the goal of this model is met. To mitigate the risk of systematic wrong-classification, in the work-classification phase, none of the keywords conveys a sentiment.") | |
st.write("You should expect that around 4 percent of all the tweets **containing potentially work-related words**, to be classified as work-related by this app.") | |
st.write("This model is powered by Joe Davison GoEmotions-based model and HuggingFace for the sentiment-labeling phase and for the work-labeling phase it is powered by HuggingFace, DistilBERT, Streamlit and, the Active Label Selection (ALS) method developed by Sepehr Cyrusian as a part of the article co-written by professor Colin P. Green") | |
with st.form(key='my_form'): | |
text_input = st.text_area("Please copy and paste the exact tweet content containing potentially work-related words below, submit and wait for around 15 seconds for the results of this online demo which has much worse FN and FP than the original model.",'I enjoy working with my manager', max_chars=280) | |
submit_button = st.form_submit_button(label='Submit') | |
ddd=demojj(text_input) | |
st.write('Affect: ' + sentimentor(ddd)) | |
sha = ["admiration","amusement","approval","caring","desire","excitement", "gratitude", "joy", "love", "optimism", "pride", "relief"] | |
gha = ["anger","annoyance","disappointment", "disapproval", "disgust", "embarrassment", "fear","grief", "nervousness", "remorse", "sadness"] | |
kha=["confusion","curiosity","realization","surprise"] | |
for i in sha: | |
if(i == sentimentor(ddd)) : | |
st.write("Sentiment: ") | |
new_title = '<p style="background-image: linear-gradient(to left, rgba(200,255,198,0), rgba(206,255,218,1));font-size: 36px;">Positive</p>' | |
st.markdown(new_title, unsafe_allow_html=True) | |
for i in gha: | |
if(i == sentimentor(ddd)) : | |
st.write("Sentiment: ") | |
new_title = '<p style="background-image: linear-gradient(to left, rgba(255,198,198,0), rgba(255,206,206,1));font-size: 36px;">Negative</p>' | |
st.markdown(new_title, unsafe_allow_html=True) | |
for i in kha: | |
if(i == sentimentor(ddd)) : | |
st.write("Sentiment: ") | |
new_title = '<p style="background-image: linear-gradient(to right, orange,yellow,blue,indigo,violet);font-size: 36px;">Ambiguous</p>' | |
st.markdown(new_title, unsafe_allow_html=True) | |
#text-decoration: underline; text-decoration-color: green; | |
#st.metric(label="Sentiment", value=sentimentor(ddd), delta="+") | |
dade=appendor(text_input) | |
if allll(dade)==0: | |
st.write('This tweet **is related to work** and it might be related to pecuniary aspects of work or work itself.') | |
elif allll(dade)==1: | |
st.write('This tweet **is related to work** and it might be related to talking about or addressing colleagues (or others).') | |
elif allll(dade)==2: | |
st.write('This tweet **is related to work** and it might be related to boss or alike.') | |
elif allll(dade)==3: | |
st.write('This tweet **is related to work** and it might be related to the time dimension or general aspect of work.') | |
elif allll(dade)==4: | |
st.write('This tweet **is related to work** and it might be related to the time dimension or general aspect of work.') | |
elif allll(dade)=='None': | |
st.write('The model could not find this tweet to be related to work.') | |
st.warning('Compared to the original model, this small online demo is slower and has a **much worse** false-negative and false-positive rates. Therefore this open-source online demo can be used as a **cross-checker for the tweets already tagged by the main model, hence showing its ability to solve the problem of working with big data**. The main model yields a better confusion matrix in recognizing work-related texts task and is more than 20 times faster. Due to the randomness of the model, in sporadic cases, the same text might be labeled differently in the second submission, which should- believing in statistics!- be corrected in the third one.') | |
st.info('Please cite the respective paper written by Sepehr Cyrusian and professor Colin P. Green if you use the files of this demo in whole or in part.') | |
st.info('Conceptualization, data collection, cloud computing, storage management, design and, implementation required for this AI model/app to be made is done by Sepehr Cyrusian as a demo for a part of the article co-written by professor Colin P. Green.') |