juliaannjose commited on
Commit
8360753
·
1 Parent(s): ab29a45

sentiment analysis code

Browse files
Files changed (1) hide show
  1. app.py +25 -2
app.py CHANGED
@@ -1,4 +1,27 @@
1
  import streamlit as st
 
2
 
3
- x = st.slider("Select a value")
4
- st.write(x, "squared is", x * x)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ # widget for selecting langugae model
5
+ # available sentiment analysis models: https://huggingface.co/models?pipeline_tag=text-classification&sort=downloads&search=sentiment
6
+ # we take the first 5 most downloaded ones.
7
+ language_model = st.selectbox(
8
+ "Select the Pretrained Language Model you'd like to use",
9
+ (
10
+ "finiteautomata/bertweet-base-sentiment-analysis",
11
+ "siebert/sentiment-roberta-large-english",
12
+ "cardiffnlp/twitter-roberta-base-sentiment",
13
+ "Seethal/sentiment_analysis_generic_dataset",
14
+ "nlptown/bert-base-multilingual-uncased-sentiment",
15
+ ),
16
+ )
17
+
18
+ # pass the model to transformers pipeline - model selection component.
19
+ sentiment_analysis = pipeline(model=language_model)
20
+
21
+ # get text entry from users
22
+ data = st.text_input(
23
+ "Enter Text", "Just started school at NYU! Looking forward to this new chapter!"
24
+ )
25
+
26
+ results = sentiment_analysis([data])
27
+ st.write(results)