Spaces:
Runtime error
Runtime error
Jeffrey Rathgeber Jr
commited on
testblob tester up
Browse files
app.py
CHANGED
@@ -17,24 +17,16 @@ preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in
|
|
17 |
st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
|
18 |
|
19 |
# textblob
|
20 |
-
|
21 |
-
sentiment
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
# if score < 0:
|
33 |
-
# return 'Negative'
|
34 |
-
# elif score == 0:
|
35 |
-
# return 'Neutral'
|
36 |
-
# else:
|
37 |
-
# return 'Positive'
|
38 |
-
# df['polarity'] = df[text].apply(textblob_polarity)
|
39 |
-
# df['classification'] = df['polarity'].apply(getAnalysis)
|
40 |
|
|
|
17 |
st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
|
18 |
|
19 |
# textblob
|
20 |
+
def textblob_polarity(text):
|
21 |
+
return TextBlob(text).sentiment.polarity
|
22 |
+
def getAnalysis(score):
|
23 |
+
if score < 0:
|
24 |
+
return 'Negative'
|
25 |
+
elif score == 0:
|
26 |
+
return 'Neutral'
|
27 |
+
else:
|
28 |
+
return 'Positive'
|
29 |
+
df['polarity'] = df[text].apply(textblob_polarity)
|
30 |
+
df['classification'] = df['polarity'].apply(getAnalysis)
|
31 |
+
st.write('According to textblob, input text is ', df['classification'], ' with a polarity (subjectivity score) of ', df['polarity'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|