def get_good_pos_ngrams(self):
if(os.path.isfile(NGRAM_PATH)):<EOL><INDENT>good_pos_ngrams = pickle.load(open(NGRAM_PATH, '<STR_LIT:rb>'))<EOL><DEDENT>elif os.path.isfile(ESSAY_CORPUS_PATH):<EOL><INDENT>essay_corpus = open(ESSAY_CORPUS_PATH).read()<EOL>essay_corpus = util_functions.sub_chars(essay_corpus)<EOL>good_pos_ngrams = util_functions.regenerate_good_tokens(essay_corpus)<EOL>pickle.dump(good_pos_ngrams, open(NGRAM_PATH, '<STR_LIT:wb>'))<EOL><DEDENT>else:<EOL><INDENT>good_pos_ngrams=['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>']<EOL><DEDENT>return set(good_pos_ngrams)<EOL>
Gets a set of gramatically correct part of speech sequences from an input file called essaycorpus.txt
Returns the set and caches the file