def getTagInfo(filename, isAbsolutePath = False): """ Getting the tag information from the data file :param filename: The name of the data file :param isAbsolutePath: is the filename, the absolute path to the file :return: the list of object, where each object would be dict representing tag and word """ return util.getTaggedWords(filename, isAbsolutePath)
sentences.append(sentence_file) output = open('hmmoutput.txt', 'w') for sentence in sentences: output.write(sentence) output.close() pass if __name__ == '__main__': start = datetime.datetime.now() num_of_args = len(sys.argv) if num_of_args == 2: filename = sys.argv[1] starting_prob, transition_prob, emission_prob = getHMMModel('hmm_model.txt') file_contents = util.getUntaggedWords(filename, True) tagged_sentences = tagData(starting_prob, transition_prob, emission_prob, file_contents) # If True, would compute the accurary of the tagger if constant.COMPUTE_ACCURACY: true_value = util.getTaggedWords(constant.DEV_TAGGED_DATA) getDiff(tagged_sentences, true_value) writeOutput(tagged_sentences) end = datetime.datetime.now() print 'Took ' + str(end-start) + ' time.' pass