rohanphadke commited on
Commit
b4a58fd
1 Parent(s): ba564f3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -1,10 +1,14 @@
1
  import gradio as gr
 
 
 
2
  # from transformers import AutoTokenizer, AutoModelForSequenceClassification
3
  # import torch
4
 
5
  # pretrained = "rohanphadke/roberta-finetuned-triplebottomline"
6
  # tokenizer = AutoTokenizer.from_pretrained(pretrained)
7
  # model = AutoModelForSequenceClassification.from_pretrained(pretrained)
 
8
  # threshold = 0.5
9
 
10
  labels = {0: 'people', 1: 'planet', 2:'profit'}
@@ -15,7 +19,7 @@ def greet(name):
15
  return "Hello " + name + "!!"
16
 
17
  def predict_text(text):
18
- return return_labels, return_sentiment
19
 
20
  demo = gr.Interface(fn=predict_text, inputs="text", outputs=["label", "label"])
21
  demo.launch()
 
1
  import gradio as gr
2
+ import nltk
3
+ from nltk.sentiment import SentimentIntensityAnalyzer
4
+ nltk.download('vader_lexicon')
5
  # from transformers import AutoTokenizer, AutoModelForSequenceClassification
6
  # import torch
7
 
8
  # pretrained = "rohanphadke/roberta-finetuned-triplebottomline"
9
  # tokenizer = AutoTokenizer.from_pretrained(pretrained)
10
  # model = AutoModelForSequenceClassification.from_pretrained(pretrained)
11
+ sia = SentimentIntensityAnalyzer()
12
  # threshold = 0.5
13
 
14
  labels = {0: 'people', 1: 'planet', 2:'profit'}
 
19
  return "Hello " + name + "!!"
20
 
21
  def predict_text(text):
22
+ return return_labels, sia.polarity_scores(text)
23
 
24
  demo = gr.Interface(fn=predict_text, inputs="text", outputs=["label", "label"])
25
  demo.launch()