Spaces:
Runtime error
Runtime error
Jeffrey Rathgeber Jr
commited on
textblob
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
3 |
-
import pandas as pd
|
4 |
from transformers import pipeline
|
5 |
from textblob import TextBlob
|
6 |
|
@@ -18,16 +17,14 @@ preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in
|
|
18 |
st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
|
19 |
|
20 |
# textblob
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
df['classification'] = df['polarity'].apply(getAnalysis)
|
32 |
-
st.write('According to textblob, input text is ', df['classification'], ' with a subjectivity score of ', df['polarity'])
|
33 |
|
|
|
1 |
import streamlit as st
|
2 |
import tensorflow as tf
|
|
|
3 |
from transformers import pipeline
|
4 |
from textblob import TextBlob
|
5 |
|
|
|
17 |
st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
|
18 |
|
19 |
# textblob
|
20 |
+
polarity = TextBlob(textIn).sentiment.polarity
|
21 |
+
sentiment = TextBlob(textIn).sentiment
|
22 |
+
if score < 0:
|
23 |
+
sentiment = 'Negative'
|
24 |
+
elif score == 0:
|
25 |
+
sentiment = 'Neutral'
|
26 |
+
else:
|
27 |
+
sentiment = 'Positive'
|
28 |
+
|
29 |
+
st.write('According to textblob, input text has a subjectivity score of ', sentiment, ' and a polarity score of ', polarity)
|
|
|
|
|
30 |
|