Karthikeyan commited on
Commit
0f5cd4b
1 Parent(s): 5fc65a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
app.py CHANGED
@@ -18,11 +18,6 @@ class SentimentAnalyzer:
18
  # self.model="facebook/bart-large-mnli"
19
  openai.api_key=os.getenv("OPENAI_API_KEY")
20
  def analyze_sentiment(self, text):
21
- # pipe = pipeline("zero-shot-classification", model=self.model)
22
- # label=["positive","negative","neutral"]
23
- # result = pipe(text, label)
24
- # sentiment_scores= {result['labels'][0]:result['scores'][0],result['labels'][1]:result['scores'][1],result['labels'][2]:result['scores'][2]}
25
- # sentiment_scores_str = f"Positive: {sentiment_scores['positive']:.2f}, Neutral: {sentiment_scores['neutral']:.2f}, Negative: {sentiment_scores['negative']:.2f}"
26
  prompt = f""" Your task is find the top 3 setiments : <labels = positive, negative, neutral> and it's sentiment score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
27
  your are analyze the text and provide the output in the following json order: \"\"\"
28
  <\{result['labels'][0]: result['scores'][0], result['labels'][1]: result['scores'][1], result['labels'][2]: result['scores'][2] \}>\"\"\" \
@@ -42,6 +37,8 @@ class SentimentAnalyzer:
42
  sentiment_scores_str = response.choices[0].text.strip()
43
  print(sentiment_scores_str)
44
  return sentiment_scores_str
 
 
45
  def emotion_analysis(self,text):
46
  prompt = f""" Your task is find the top 3 emotion : <Sadness, Happiness, Joy, Fear, Disgust, Anger> and it's emotion score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
47
  your are analyze the text and provide the output in the following list format heigher to lower order: ["emotion1","emotion2","emotion3"][score1,score2,score3]''' [with top 1 result having the highest score]
@@ -70,8 +67,7 @@ class SentimentAnalyzer:
70
  # result['labels'][2]: result['scores'][2]
71
  # }
72
  prompt = f""" Your task is find the top 3 setiments : <labels = positive, negative, neutral> and it's sentiment score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
73
- your are analyze the text and provide the output in the following json order: \"\"\"
74
- <\{result['labels'][0]: result['scores'][0], result['labels'][1]: result['scores'][1], result['labels'][2]: result['scores'][2] \}>\"\"\" \
75
  analyze the text : '''{text}'''
76
  """
77
  response = openai.Completion.create(
 
18
  # self.model="facebook/bart-large-mnli"
19
  openai.api_key=os.getenv("OPENAI_API_KEY")
20
  def analyze_sentiment(self, text):
 
 
 
 
 
21
  prompt = f""" Your task is find the top 3 setiments : <labels = positive, negative, neutral> and it's sentiment score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
22
  your are analyze the text and provide the output in the following json order: \"\"\"
23
  <\{result['labels'][0]: result['scores'][0], result['labels'][1]: result['scores'][1], result['labels'][2]: result['scores'][2] \}>\"\"\" \
 
37
  sentiment_scores_str = response.choices[0].text.strip()
38
  print(sentiment_scores_str)
39
  return sentiment_scores_str
40
+
41
+
42
  def emotion_analysis(self,text):
43
  prompt = f""" Your task is find the top 3 emotion : <Sadness, Happiness, Joy, Fear, Disgust, Anger> and it's emotion score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
44
  your are analyze the text and provide the output in the following list format heigher to lower order: ["emotion1","emotion2","emotion3"][score1,score2,score3]''' [with top 1 result having the highest score]
 
67
  # result['labels'][2]: result['scores'][2]
68
  # }
69
  prompt = f""" Your task is find the top 3 setiments : <labels = positive, negative, neutral> and it's sentiment score for the Mental Healthcare Doctor Chatbot and patient conversation text.\
70
+ your are analyze the text and provide the output in the following json format heigher to lower order: \"\"\"<label1: score1, label2:score2, label3:score3>\"\"\" \
 
71
  analyze the text : '''{text}'''
72
  """
73
  response = openai.Completion.create(