Jeffrey Rathgeber Jr commited on
Commit
0a5c8ee
·
unverified ·
1 Parent(s): c38e40d

testblob tester up

Browse files
Files changed (1) hide show
  1. app.py +12 -20
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
- polarity = TextBlob(textIn).sentiment.polarity
21
- sentiment = ''
22
- if score < 0:
23
- sentiment = 'Negative'
24
- elif score == 0:
25
- sentiment = 'Neutral'
26
- else:
27
- sentiment = 'Positive'
28
- st.write('According to textblob, input text is ', sentiment, ' with a polarity (subjectivity score) of ', polarity)
29
-
30
-
31
- # def getAnalysis(score):
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