-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSentence.py
58 lines (44 loc) · 1.36 KB
/
Sentence.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
class Sentence:
def __init__(self, id_sentence, sentiment_value, sentiment, xml_name):
self._number_of_tokens = 0
self._sentiment_value = sentiment_value
self._tokens=[]
self._aspects=[]
self._xml = xml_name
self._id_sentence = id_sentence
self._sentiment = sentiment
self._joined_string = ''.join(self._tokens)
@property
def number_of_tokens(self):
return self._number_of_tokens
@property
def sentiment_value(self):
return self._sentiment_value
@property
def tokens(self):
return self._tokens
@property
def aspects(self):
return self._aspects
@property
def xml(self):
return self._xml
@property
def id_sentence(self):
return self._id_sentence
@property
def sentiment(self):
return self._sentiment
@number_of_tokens.setter
def number_of_tokens(self, number_of_tokens):
self._number_of_tokens = number_of_tokens
def add_token(self, new_token):
self._tokens.append(new_token)
def add_aspect(self, aspect):
self._aspects.append(aspect)
def __str__(self):
return ' '.join(self._tokens)
'''@property
def joined_string(self):
return ''.join(self._tokens)
'''