File size: 715 Bytes
a310704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# app.py
import streamlit as st
from transformers import pipeline
from textblob import TextBlob

pipe = pipeline('sentiment-analysis')
st.title("Hugging Face Sentiment Analysis Spaces Example")
st.subheader("What framework would you like to use for Sentiment Analysis")
#Picking what NLP task you want to do
option = st.selectbox('Framework',('Transformers', 'TextBlob')) #option is stored in this variable
#Textbox for text user is entering
st.subheader("Enter the text you'd like to analyze.")
text = st.text_input('Enter text') #text is stored in this variable

if option == 'Transformers':
    out = pipe(text)
else:
    out = TextBlob(text)
    out = out.sentiment
st.write("Sentiment of Text: ")
st.write(out)