-
Notifications
You must be signed in to change notification settings - Fork 0
/
analyzer.py
35 lines (22 loc) · 904 Bytes
/
analyzer.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
from models.sentence import Sentence
import re
class Analyzer:
def __init__(self):
super(Analyzer, self).__init__()
self.type = Sentence(out="type")
self.tag = Sentence(out="tag", bag_type="pos")
def isAboutYou(self, value):
matches = re.findall(r"(?<![a-zA-Z])(you|your|u|voce|você|vc)(?![a-zA-Z])", value.lower())
return bool(len(matches))
def isNegative(self, value):
predicted = self.type.predict(value)
return predicted["type"] == "negative" if predicted else False
def isQuestion(self, value):
predicted = self.type.predict(value)
return predicted["type"] == "question" if predicted else False
def isAffirmative(self, value):
predicted = self.type.predict(value)
return predicted["type"] == "affirmative" if predicted else False
def isOrder(self, value):
predicted = self.type.predict(value)
return predicted["type"] == "order" if predicted else False