#NEWLINE# def featurize( self , text ) : #NEWLINE# #INDENT# if ( hash ( text ) != self . _cache ) : #NEWLINE# #INDENT# self . _cache = hash ( text ) #NEWLINE# feats = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# total = alphanum . sub ( ' ' , unidecode ( text . lower ( ) ) ) #NEWLINE# total = total . split ( ) #NEWLINE# bgs = set ( ngrams ( total , 2 ) ) #NEWLINE# for bg in bgs . intersection ( self . _bigrams ) : #NEWLINE# #INDENT# feats [ bg ] = 1.0 #NEWLINE# #UNINDENT# for word in total : #NEWLINE# #INDENT# feats [ word ] = 1.0 #NEWLINE# #UNINDENT# self . _pd = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for cc in self . _classifiers : #NEWLINE# #INDENT# self . _pd [ cc ] = self . _classifiers [ cc ] . prob_classify ( feats ) #NEWLINE# #UNINDENT# #UNINDENT# return self . _pd