1 '''
2 Created on 14/03/2014
3
4 @author: David Vilares
5 '''
6
7
8 from miopia.analyzer.counter.LexiconCounter import LexiconCounter
9 from miopia.util.TokenInfo import TokenInfo
10 from nltk.util import ngrams
11
12
14
15 '''
16 This counter to manage counters which use external knowledge to obtain
17 features for the supervised classifier.
18 '''
19
20 - def __init__(self, ftc, preprocessor, lexical_processor,
21 dict_lexicon,lowercase=True):
22
23 '''
24 @param ftc: An instance of L{FeatureTypeConfiguration}
25 @param preprocessor: An instance of L{PreprocessorI}
26 @param lexical_processor: An instance of L{LexicalProcessor}
27 @param dict_lexicon: A nested dictionary {key:[Category,{key:[ ... ]}]}
28 @param lowercase: A boolean. True to ignore capitalised characters.
29 '''
30 super(AbstractedLexiconsCounter,self).__init__(ftc,preprocessor,
31 lexical_processor,
32 dict_lexicon, lowercase)
33
34
36 for t in list_tokens:
37 print t,
38
39
41 try:
42 d[self._id_of_feature(textid, initial_position, value)]+=1
43 except KeyError:
44 d[self._id_of_feature(textid, initial_position, value)]=1
45 return d
46