#NEWLINE# def lemmatize( method , data ) : #NEWLINE# #INDENT# '\n\tTakes an array of words or array of tupples containing words and pos tags.\n\tBoth Penn and Wordnet tags are supported\n\t' #NEWLINE# data = parse_input ( data ) #NEWLINE# if ( res == False ) : #NEWLINE# #INDENT# return ret_failure ( 703 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# res = [ ] #NEWLINE# if ( method == 'wordnet' ) : #NEWLINE# #INDENT# for word in data : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( type ( word ) is list ) : #NEWLINE# #INDENT# res . append ( [ word [ 0 ] , WordnetLm . lemmatize ( word [ 0 ] , penn_to_wn ( word [ 1 ] ) ) ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# res . append ( [ word , WordnetLm . lemmatize ( word ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# except LookupError : #NEWLINE# #INDENT# return ret_failure ( 704 ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# return ret_failure ( 702 ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# abort ( 404 ) #NEWLINE# #UNINDENT# return ret_success ( res )