Package miopia :: Package analyzer :: Package counter :: Module SintacticCounter
[hide private]
[frames] | no frames]

Source Code for Module miopia.analyzer.counter.SintacticCounter

 1  ''' 
 2  Created on 13/05/2014 
 3   
 4  @author: david.vilares 
 5  ''' 
 6   
 7  from miopia.analyzer.counter.Counter import Counter 
 8   
9 -class SintacticCounter(Counter):
10 ''' 11 An abstract class which provides the basic operations for the counters 12 which rely on instances of L{SentimentDependencyGraph} to carry out their 13 analysis. 14 ''' 15 16
17 - def __init__(self,ftc):
18 ''' 19 @param ftc: An instance of L{FeatureTypeConfiguration} 20 ''' 21 super(SintacticCounter,self).__init__(ftc)
22
23 - def _count(self, list_text_info):
24 """ 25 @param list_text_info: A list of L{TextInfo} objects 26 """ 27 dict_features = {} 28 graphs = [(text_info.get_textid(),text_info.get_dependency_graphs()) 29 for text_info in list_text_info] 30 31 for textid, text_graphs in graphs: 32 for text_graph,address in text_graphs: 33 self._count_graph(textid,text_graph,address) 34 dict_graph= self._count_graph(textid,text_graph, address) 35 36 for key in dict_graph.keys(): 37 try: 38 dict_features[key]+= 1 39 except KeyError: 40 dict_features[key] = 1 41 42 return dict_features
43
44 - def _count_graph(self,textid,dg,address):
45 raise NotImplementedError
46