forked from DouglasCorreiaBrito/tcc-fateczl-2020
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsentiment.py
35 lines (28 loc) · 805 Bytes
/
sentiment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import brain
class Sentiment:
def __init__(self, text, language):
self._text = text
self._language = language
@property
def text(self):
return self._text
@property
def language(self):
return self._language
def analyze_feeling(self):
if self._language not in 'pt_BR':
return 'olan'
if ":(" in self._text:
self._text = "ruim"
prediction = brain.predict(self._text)
pontuacao_final = 0
list_punct = []
for pontuacao in prediction:
list_punct.append(pontuacao)
pontuacao_final += pontuacao
if pontuacao_final < -0.5:
return 'neg'
elif pontuacao_final > 0.5:
return 'pos'
else:
return 'neu'