#NEWLINE# def find_lemmata( tokens ) : #NEWLINE# #INDENT# ' Annotates the tokens with lemmata for plural nouns and conjugated verbs,\n        where each token is a [word, part-of-speech] list.\n    ' #NEWLINE# for token in tokens : #NEWLINE# #INDENT# ( word , pos , lemma ) = ( token [ 0 ] , token [ 1 ] , token [ 0 ] ) #NEWLINE# if ( pos . startswith ( 'JJ' ) and word . endswith ( 'e' ) ) : #NEWLINE# #INDENT# lemma = predicative ( word ) #NEWLINE# #UNINDENT# if ( pos == 'NNS' ) : #NEWLINE# #INDENT# lemma = singularize ( word ) #NEWLINE# #UNINDENT# if pos . startswith ( ( 'VB' , 'MD' ) ) : #NEWLINE# #INDENT# lemma = ( conjugate ( word , INFINITIVE ) or word ) #NEWLINE# #UNINDENT# token . append ( lemma . lower ( ) ) #NEWLINE# #UNINDENT# return tokens