Chris4K commited on
Commit
e7e4d1a
1 Parent(s): 288975e

Update sentiment_analysis.py

Browse files
Files changed (1) hide show
  1. sentiment_analysis.py +5 -4
sentiment_analysis.py CHANGED
@@ -1,8 +1,9 @@
1
  import requests
2
  import gradio as gr
3
  from transformers import pipeline
 
4
 
5
- class SentimentAnalysisTool:
6
  name = "sentiment_analysis"
7
  description = "This tool analyses the sentiment of a given text input."
8
 
@@ -11,7 +12,7 @@ class SentimentAnalysisTool:
11
  outputs = ["json"]
12
 
13
  def __call__(self, inputs: str):
14
- return SentimentAnalysisTool.predicto(str)
15
 
16
  model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
17
  model_id_2 = "microsoft/deberta-xlarge-mnli"
@@ -33,10 +34,10 @@ class SentimentAnalysisTool:
33
  classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
34
 
35
  def predicto(review):
36
- classifier = SentimentAnalysisTool.get_prediction(SentimentAnalysisTool.model_id_3)
37
  prediction = classifier(review)
38
  print(prediction)
39
- return SentimentAnalysisTool.parse_output(prediction)
40
 
41
 
42
 
 
1
  import requests
2
  import gradio as gr
3
  from transformers import pipeline
4
+ from transformers import Tool
5
 
6
+ class SentimentAnalysisTool(Tool):
7
  name = "sentiment_analysis"
8
  description = "This tool analyses the sentiment of a given text input."
9
 
 
12
  outputs = ["json"]
13
 
14
  def __call__(self, inputs: str):
15
+ return predicto(str)
16
 
17
  model_id_1 = "nlptown/bert-base-multilingual-uncased-sentiment"
18
  model_id_2 = "microsoft/deberta-xlarge-mnli"
 
34
  classifier = pipeline("text-classification", model=model_id, return_all_scores=True)
35
 
36
  def predicto(review):
37
+ classifier = get_prediction(model_id_3)
38
  prediction = classifier(review)
39
  print(prediction)
40
+ return parse_output(prediction)
41
 
42
 
43