Spaces:
Sleeping
Sleeping
Kingston Yip
commited on
Commit
•
a222015
1
Parent(s):
41b1885
updates
Browse files
app.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
pipe = pipeline(task="sentiment-analysis")
|
6 |
st.title("Toxic Tweets Analyzer")
|
7 |
|
8 |
#form
|
9 |
with st.form("my_form"):
|
10 |
submitted = st.form_submit_button("Analyze")
|
11 |
-
st.text_area("enter tweet here:")
|
12 |
-
text = st.write("i'm nice at ping pong")
|
13 |
if submitted:
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
|
|
4 |
pipe = pipeline(task="sentiment-analysis")
|
5 |
st.title("Toxic Tweets Analyzer")
|
6 |
|
7 |
#form
|
8 |
with st.form("my_form"):
|
9 |
submitted = st.form_submit_button("Analyze")
|
10 |
+
tweet = st.text_area("enter tweet here:", value="i'm nice at ping pong")
|
|
|
11 |
if submitted:
|
12 |
+
out = pipe(tweet)
|
13 |
+
|
14 |
+
# print out nicely
|
15 |
+
sentiment = out[0]['label']
|
16 |
+
score = out[0]['score']
|
17 |
+
print(f"{tweet} \nsentiment: {sentiment} \nscore: {score}")
|