#NEWLINE# def science_text( cls , max_nb_chars = 200 ) : #NEWLINE# #INDENT# "\n        Generate a text string.\n        Depending on the $maxNbChars, returns a string made of words, sentences, or paragraphs.\n        :example 'Sapiente sunt omnis. Ut pariatur ad autem ducimus et. Voluptas rem voluptas sint modi dolorem amet.'\n        :param max_nb_chars Maximum number of characters the text should contain (minimum 5)\n        :return string\n        " #NEWLINE# text = [ ] #NEWLINE# if ( max_nb_chars < 5 ) : #NEWLINE# #INDENT# raise ValueError ( 'text() can only generate text of at least 5 characters' ) #NEWLINE# #UNINDENT# if ( max_nb_chars < 25 ) : #NEWLINE# #INDENT# while ( not text ) : #NEWLINE# #INDENT# size = 0 #NEWLINE# while ( size < max_nb_chars ) : #NEWLINE# #INDENT# word = ( ( ' ' if size else '' ) + cls . science_word ( ) ) #NEWLINE# text . append ( word ) #NEWLINE# size += len ( word ) #NEWLINE# #UNINDENT# text . pop ( ) #NEWLINE# #UNINDENT# text [ 0 ] = ( text [ 0 ] [ 0 ] . upper ( ) + text [ 0 ] [ 1 : ] ) #NEWLINE# last_index = ( len ( text ) - 1 ) #NEWLINE# text [ last_index ] += '.' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( max_nb_chars < 100 ) : #NEWLINE# #INDENT# while ( not text ) : #NEWLINE# #INDENT# size = 0 #NEWLINE# while ( size < max_nb_chars ) : #NEWLINE# #INDENT# sentence = ( ( ' ' if size else '' ) + cls . science_sentence ( ) ) #NEWLINE# text . append ( sentence ) #NEWLINE# size += len ( sentence ) #NEWLINE# #UNINDENT# text . pop ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# while ( not text ) : #NEWLINE# #INDENT# size = 0 #NEWLINE# while ( size < max_nb_chars ) : #NEWLINE# #INDENT# paragraph = ( ( '\n' if size else '' ) + cls . science_paragraph ( ) ) #NEWLINE# text . append ( paragraph ) #NEWLINE# size += len ( paragraph ) #NEWLINE# #UNINDENT# text . pop ( ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return '' . join ( text )