Spaces:
Runtime error
Runtime error
Update analyzer.py
Browse files- analyzer.py +3 -24
analyzer.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
from openai import AzureOpenAI
|
| 2 |
client = AzureOpenAI()
|
| 3 |
-
|
| 4 |
class SentimentAnalyzer:
|
| 5 |
def __init__(self):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
def analyze_sentiment(self, text):
|
| 10 |
conversation = [
|
|
@@ -45,27 +44,7 @@ class SentimentAnalyzer:
|
|
| 45 |
|
| 46 |
return message
|
| 47 |
|
| 48 |
-
|
| 49 |
-
pipe = pipeline("zero-shot-classification", model=self.model)
|
| 50 |
-
label=["positive", "negative", "neutral"]
|
| 51 |
-
result = pipe(text, label)
|
| 52 |
-
sentiment_scores = {
|
| 53 |
-
result['labels'][0]: result['scores'][0],
|
| 54 |
-
result['labels'][1]: result['scores'][1],
|
| 55 |
-
result['labels'][2]: result['scores'][2]
|
| 56 |
-
}
|
| 57 |
-
return sentiment_scores
|
| 58 |
-
|
| 59 |
-
def emotion_analysis_for_graph(self,text):
|
| 60 |
-
|
| 61 |
-
list_of_emotion=text.split(":")
|
| 62 |
-
label=list_of_emotion[1]
|
| 63 |
-
score=list_of_emotion[2]
|
| 64 |
-
score_dict={
|
| 65 |
-
label:float(score)
|
| 66 |
-
}
|
| 67 |
-
|
| 68 |
-
return score_dict
|
| 69 |
|
| 70 |
|
| 71 |
class Summarizer:
|
|
|
|
| 1 |
from openai import AzureOpenAI
|
| 2 |
client = AzureOpenAI()
|
| 3 |
+
|
| 4 |
class SentimentAnalyzer:
|
| 5 |
def __init__(self):
|
| 6 |
+
pass
|
|
|
|
| 7 |
|
| 8 |
def analyze_sentiment(self, text):
|
| 9 |
conversation = [
|
|
|
|
| 44 |
|
| 45 |
return message
|
| 46 |
|
| 47 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
class Summarizer:
|