Spaces:
Runtime error
Runtime error
Ariel Hsieh
commited on
Commit
•
e4f9c2a
1
Parent(s):
1bc7870
update
Browse files
app.py
CHANGED
@@ -3,48 +3,53 @@ from transformers import pipeline
|
|
3 |
from pysentimiento import create_analyzer
|
4 |
|
5 |
#title
|
6 |
-
st.title("
|
7 |
|
8 |
model = st.selectbox("Which pretrained model would you like to use?",("roberta-large-mnli","twitter-XLM-roBERTa-base","bertweet-sentiment-analysis"))
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
|
50 |
|
|
|
3 |
from pysentimiento import create_analyzer
|
4 |
|
5 |
#title
|
6 |
+
st.title("Toxic Tweets")
|
7 |
|
8 |
model = st.selectbox("Which pretrained model would you like to use?",("roberta-large-mnli","twitter-XLM-roBERTa-base","bertweet-sentiment-analysis"))
|
9 |
|
10 |
+
d = {'col1':[1,2],'col2':[3,4]}
|
11 |
+
data = pd.DataFrame(data=d)
|
12 |
+
st.table(data)
|
13 |
+
|
14 |
+
|
15 |
+
# data = []
|
16 |
+
# text = st.text_input("Enter text here:","Artificial Intelligence is useful")
|
17 |
+
# data.append(text)
|
18 |
+
# if model == "roberta-large-mnli":
|
19 |
+
# #1
|
20 |
+
# if st.button("Run Sentiment Analysis of Text"):
|
21 |
+
# model_path = "roberta-large-mnli"
|
22 |
+
# sentiment_pipeline = pipeline(model=model_path)
|
23 |
+
# result = sentiment_pipeline(data)
|
24 |
+
# label = result[0]["label"]
|
25 |
+
# score = result[0]["score"]
|
26 |
+
# st.write("The classification of the given text is " + label + " with a score of " + str(score))
|
27 |
+
# elif model == "twitter-XLM-roBERTa-base":
|
28 |
+
# #2
|
29 |
+
# if st.button("Run Sentiment Analysis of Text"):
|
30 |
+
# model_path = "cardiffnlp/twitter-xlm-roberta-base-sentiment"
|
31 |
+
# sentiment_task = pipeline("sentiment-analysis", model=model_path, tokenizer=model_path)
|
32 |
+
# result = sentiment_task(text)
|
33 |
+
# label = result[0]["label"].capitalize()
|
34 |
+
# score = result[0]["score"]
|
35 |
+
# st.write("The classification of the given text is " + label + " with a score of " + str(score))
|
36 |
+
|
37 |
+
# elif model == "bertweet-sentiment-analysis":
|
38 |
+
# #3
|
39 |
+
# if st.button("Run Sentiment Analysis of Text"):
|
40 |
+
# analyzer = create_analyzer(task="sentiment", lang="en")
|
41 |
+
# result = analyzer.predict(text)
|
42 |
+
# if result.output == "POS":
|
43 |
+
# label = "POSITIVE"
|
44 |
+
# elif result.output == "NEU":
|
45 |
+
# label = "NEUTRAL"
|
46 |
+
# else:
|
47 |
+
# label = "NEGATIVE"
|
48 |
|
49 |
+
# neg = result.probas["NEG"]
|
50 |
+
# pos = result.probas["POS"]
|
51 |
+
# neu = result.probas["NEU"]
|
52 |
+
# st.write("The classification of the given text is " + label + " with the scores broken down as: Positive - " + str(pos) + ", Neutral - " + str(neu) + ", Negative - " + str(neg))
|
53 |
|
54 |
|
55 |
|