Package miopia :: Package preparator :: Module LexicalSentimentInfo
[hide private]
[frames] | no frames]

Source Code for Module miopia.preparator.LexicalSentimentInfo

 1  ''' 
 2  @author: David Vilares 
 3  ''' 
 4   
 5  from collections import defaultdict 
 6   
 7   
8 -class LexicalValenceShifter(object):
9 ''' 10 It describes the phemonona supported by the class L{LexicalSentimentInfo} 11 ''' 12 REPLICATION = "REPLICATION" 13 CAPS = "CAPS"
14 15
16 -class LexicalSentimentInfo(object):
17 #TODO: Correctly integrate with the remainder of the system 18 ''' 19 This class stores auxiliary information about the no preprocessed text 20 that could be useful in next steps 21 '''
22 - def __init__(self):
23 ''' 24 Constructor 25 ''' 26 #dict has set's as values 27 self._dict = defaultdict(defaultdict)
28 29
30 - def add_lexical_valence_shifter(self,id_sentence,id_token, 31 type_valence_shifter):
32 try: 33 self._dict[id_sentence][id_token].append(type_valence_shifter) 34 except KeyError: 35 self._dict[id_sentence][id_token] = [type_valence_shifter]
36 37
38 - def get_dict(self):
39 return self._dict
40
41 - def get_sentence_info(self,id_sentence):
42 try: 43 return self._dict[id_sentence] 44 except: 45 return None
46 47
48 - def get_element(self,id_sentence,id_token):
49 try: 50 return self._dict[id_sentence][id_token] 51 except: 52 return None
53