Spaces:
Runtime error
Runtime error
Commit
•
22d6db5
1
Parent(s):
0092824
Delete engine.py
Browse files
engine.py
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
from transformers import pipeline
|
2 |
-
|
3 |
-
class SentimentAnalyzer:
|
4 |
-
def __init__(self) -> None:
|
5 |
-
self.analyzer = pipeline("sentiment-analysis", model = "distilbert-base-uncased-finetuned-sst-2-english")
|
6 |
-
|
7 |
-
def score_sentiment(self, sentence: str) -> float:
|
8 |
-
return self.analyzer(sentence)[0]
|
9 |
-
|
10 |
-
def get_sentiment(self, sentence: str) -> str:
|
11 |
-
sentiment_score = self.score_sentiment(sentence)
|
12 |
-
return sentiment_score['label']
|
13 |
-
|
14 |
-
if __name__ == "__main__":
|
15 |
-
sentence = "This place is good"
|
16 |
-
sentiment_analyzer = SentimentAnalyzer()
|
17 |
-
print(sentiment_analyzer.get_sentiment(sentence))
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|