#NEWLINE# def generate_new_text( self , text ) : #NEWLINE# #INDENT# no_punctuation = re . sub ( '[^A-Za-z0-9]' , ' ' , text . lower ( ) ) #NEWLINE# no_punctuation = re . sub ( '\\s+' , ' ' , no_punctuation ) #NEWLINE# corrected = self . spell_correct_text ( no_punctuation ) #NEWLINE# corrected = [ self . stemmer . stem ( w ) for w in corrected ] #NEWLINE# new = ' ' . join ( corrected ) #NEWLINE# return new