Jeffrey Rathgeber Jr commited on
Commit
d016980
·
unverified ·
1 Parent(s): 21c6b31
Files changed (1) hide show
  1. app.py +10 -13
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
- def textblob_polarity(text):
22
- return TextBlob(text).sentiment.polarity
23
- def getAnalysis(score):
24
- if score < 0:
25
- return 'Negative'
26
- elif score == 0:
27
- return 'Neutral'
28
- else:
29
- return 'Positive'
30
- df['polarity'] = df[text].apply(textblob_polarity)
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