shubhamjaiswar commited on
Commit
cbe067e
·
1 Parent(s): 067ba2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -18
app.py CHANGED
@@ -1,20 +1,7 @@
 
1
  import gradio as gr
2
- from nltk.sentiment.vader import SentimentIntensityAnalyzer
3
- import nltk
4
- nltk.download('vader_lexicon')
5
- def sentiment_analysis(sentiment_text):
6
- score = SentimentIntensityAnalyzer().polarity_scores(sentiment_text)
7
- print(score)
8
- if score['neg']>=0.5:
9
- return "Negative Feedback"
10
- elif score['pos']>=0.5:
11
- return "Positive Feedback"
12
- elif score['compound']<(-0.3):
13
- return "Negative Feedback"
14
- elif score['compound']>0.3:
15
- return "Positive Feedback"
16
- else:
17
- return "Neutral Feedback"
18
-
19
- iface = gr.Interface(fn = sentiment_analysis , inputs=['text'] , outputs=['text'])
20
  iface.launch(share=True)
 
1
+ from transformers import pipeline
2
  import gradio as gr
3
+ sentimentAnalyzer = pipeline("sentiment-analysis")
4
+ def predict_sentiment(text):
5
+ return sentimentAnalyzer(text)[0]['label']
6
+ iface = gr.Interface(fn=predict_sentiment,inputs=["text"],outputs=["text"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface.launch(share=True)