Spaces:
Runtime error
Runtime error
wira.indra
commited on
Commit
·
acee695
1
Parent(s):
74046b8
add twitter feature
Browse files
app.py
CHANGED
|
@@ -2,9 +2,7 @@ from transformers import pipeline
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import twitter_scraper as ts
|
| 4 |
|
| 5 |
-
|
| 6 |
import gradio as gr
|
| 7 |
-
from gradio.mix import Parallel
|
| 8 |
|
| 9 |
pretrained_sentiment = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
| 10 |
pretrained_ner = "cahya/bert-base-indonesian-NER"
|
|
@@ -42,8 +40,14 @@ def sentiment_ner(text):
|
|
| 42 |
def sentiment_df(df):
|
| 43 |
text_list = list(df["Text"].astype(str).values)
|
| 44 |
result = [sentiment_analysis(text) for text in text_list]
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
return df
|
| 48 |
|
| 49 |
|
|
|
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import twitter_scraper as ts
|
| 4 |
|
|
|
|
| 5 |
import gradio as gr
|
|
|
|
| 6 |
|
| 7 |
pretrained_sentiment = "w11wo/indonesian-roberta-base-sentiment-classifier"
|
| 8 |
pretrained_ner = "cahya/bert-base-indonesian-NER"
|
|
|
|
| 40 |
def sentiment_df(df):
|
| 41 |
text_list = list(df["Text"].astype(str).values)
|
| 42 |
result = [sentiment_analysis(text) for text in text_list]
|
| 43 |
+
labels = []
|
| 44 |
+
scores = []
|
| 45 |
+
for pred in result:
|
| 46 |
+
idx = list(pred.values()).index(max(list(pred.values())))
|
| 47 |
+
labels.append(list(pred.keys())[idx])
|
| 48 |
+
scores.append(round(list(pred.values())[idx], 3))
|
| 49 |
+
df['Label'] = labels
|
| 50 |
+
df['Score'] = scores
|
| 51 |
return df
|
| 52 |
|
| 53 |
|