#NEWLINE# def train( self , data ) : #NEWLINE# #INDENT# '\n        Uses a set of tagged data to train the tagger.\n        If an unknown word tagger is specified,\n        it is trained on the same data.\n\n        :param data: List of lists of (word, tag) tuples\n        :type data: tuple(str)\n        ' #NEWLINE# C = False #NEWLINE# if ( ( self . _unk is not None ) and ( self . _T == False ) ) : #NEWLINE# #INDENT# self . _unk . train ( data ) #NEWLINE# #UNINDENT# for sent in data : #NEWLINE# #INDENT# history = [ ( 'BOS' , False ) , ( 'BOS' , False ) ] #NEWLINE# for ( w , t ) in sent : #NEWLINE# #INDENT# if ( self . _C and w [ 0 ] . isupper ( ) ) : #NEWLINE# #INDENT# C = True #NEWLINE# #UNINDENT# self . _wd [ w ] [ t ] += 1 #NEWLINE# self . _uni [ ( t , C ) ] += 1 #NEWLINE# self . _bi [ history [ 1 ] ] [ ( t , C ) ] += 1 #NEWLINE# self . _tri [ tuple ( history ) ] [ ( t , C ) ] += 1 #NEWLINE# history . append ( ( t , C ) ) #NEWLINE# history . pop ( 0 ) #NEWLINE# C = False #NEWLINE# #UNINDENT# self . _eos [ t ] [ 'EOS' ] += 1 #NEWLINE# #UNINDENT# self . _compute_lambda ( )