#NEWLINE# def test_sentence_output( self , words , max_overlap_ratio , max_overlap_total ) : #NEWLINE# #INDENT# '\n        Given a generated list of words, accept or reject it. This one rejects\n        sentences that too closely match the original text, namely those that\n        contain any identical sequence of words of X length, where X is the\n        smaller number of (a) `max_overlap_ratio` (default: 0.7) of the total\n        number of words, and (b) `max_overlap_total` (default: 15).\n        ' #NEWLINE# overlap_ratio = int ( round ( ( max_overlap_ratio * len ( words ) ) ) ) #NEWLINE# overlap_max = min ( max_overlap_total , overlap_ratio ) #NEWLINE# overlap_over = ( overlap_max + 1 ) #NEWLINE# gram_count = max ( ( len ( words ) - overlap_max ) , 1 ) #NEWLINE# grams = [ words [ i : ( i + overlap_over ) ] for i in range ( gram_count ) ] #NEWLINE# for g in grams : #NEWLINE# #INDENT# gram_joined = self . word_join ( g ) #NEWLINE# if ( gram_joined in self . rejoined_text ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# #UNINDENT# return True