def generate_additional_essays(self, e_text, e_score, dictionary=None, max_syns=<NUM_LIT:3>):
e_toks = nltk.word_tokenize(e_text)<EOL>all_syns = []<EOL>for word in e_toks:<EOL><INDENT>synonyms = util_functions.get_wordnet_syns(word)<EOL>if(len(synonyms) > max_syns):<EOL><INDENT>synonyms = random.sample(synonyms, max_syns)<EOL><DEDENT>all_syns.append(synonyms)<EOL><DEDENT>new_essays = []<EOL>for i in range(<NUM_LIT:0>, max_syns):<EOL><INDENT>syn_toks = e_toks<EOL>for z in range(<NUM_LIT:0>, len(e_toks)):<EOL><INDENT>if len(all_syns[z]) > i and (dictionary == None or e_toks[z] in dictionary):<EOL><INDENT>syn_toks[z] = all_syns[z][i]<EOL><DEDENT><DEDENT>new_essays.append("<STR_LIT:U+0020>".join(syn_toks))<EOL><DEDENT>for z in xrange(<NUM_LIT:0>, len(new_essays)):<EOL><INDENT>self.add_essay(new_essays[z], e_score, <NUM_LIT:1>)<EOL><DEDENT>
Substitute synonyms to generate extra essays from existing ones.
This is done to increase the amount of training data.
Should only be used with lowest scoring essays.
e_text is the text of the original essay.
e_score is the score of the original essay.
dictionary is a fixed dictionary (list) of words to replace.
max_syns defines the maximum number of additional essays to generate.  Do not set too high.