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

Source Code for Module miopia.analyzer.counter.RawCounter

 1  ''' 
 2  Created on 13/05/2014 
 3   
 4  @author: david.vilares 
 5  ''' 
 6   
 7  from miopia.analyzer.counter.Counter import Counter 
 8  from nltk.util import ngrams 
 9   
10 -class RawCounter(Counter):
11 ''' 12 An abstract class which provides methods for the Counters which don't need 13 to rely on the L{SentimentDependencyGraph} 14 ''' 15 16
17 - def __init__(self,ftc, lowercase=True):
18 ''' 19 @param ftc: An instance of L{FeatureTypeConfiguration} 20 @param lowercase: A boolean. True to ignore capitalised characters. 21 ''' 22 super(RawCounter,self).__init__(ftc) 23 self._lowercase = lowercase
24
25 - def raw_processing(self, list_text_info):
26 raw_texts = [(text_info.get_textid(), 27 self._preprocessor.preprocess(text_info.get_text())) 28 for text_info in list_text_info] 29 sentences = [(textid,self._lexical_processor.extract_sentences(ptext)) 30 for (textid,ptext) in raw_texts ] 31 tokens = [(textid, self._lexical_processor.extract_tokens(sentences)[0]) 32 for textid, sentences in sentences] 33 34 tags = [(textid, self._lexical_processor.extract_tags(tokens)) 35 for textid, tokens in tokens] 36 return tags
37
38 - def _filter(self,string):
39 return string.lower() if self._lowercase else string
40
41 - def _count(self, list_text_info):
42 raise NotImplementedError
43