| | |
| | 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") |
| | |
| | option = st.selectbox('Framework',('Transformers', 'TextBlob')) |
| | |
| | st.subheader("Enter the text you'd like to analyze.") |
| | text = st.text_input('Enter text') |
| |
|
| | if option == 'Transformers': |
| | out = pipe(text) |
| | else: |
| | out = TextBlob(text) |
| | out = out.sentiment |
| | st.write("Sentiment of Text: ") |
| | st.write(out) |
| |
|