File size: 678 Bytes
9782d85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import streamlit as st
from transformers import pipeline

st.title('Sentiment Analysis App')
text = st.text_input(' ')

mname = st.selectbox(
    'Select a pre-trained model',
    ['distilbert-base-uncased', 'distilbert-base-cased', 'bert-base-uncased', 'bert-base-cased',
     'cardiffnlp/twitter-roberta-base-sentiment-latest',
     'cardiffnlp/twitter-xlm-roberta-base-sentiment',
     'j-hartmann/emotion-english-distilroberta-base',
     'ProsusAI/finbert'
     ]
)

if st.button('Analyze Sentiment'):
    model = pipeline('sentiment-analysis', model=mname)
    result = model(text)[0]
    st.write(f'Sentiment: {result["label"]}')
    st.write(f'Score: {result["score"]}')