def console_loop(): # asks for the user to input a new sentence and outputs the tree... forever... print "Enter 'q' to quit" input_str = "" while input_str != "q": input_str = raw_input("Enter sentence:\n") input_str_split = split_sentence(input_str) results = sentence_parser.parse_string_list(input_str_split) result_file = open("out/result.txt", "w+") result_file.truncate() result_file.write("possible trees:\n") for result in results: print tree_str(result) result_file.write(tree_str(result)) result_file.close()
def parse(sentence_str): split_sentence = console.split_sentence(sentence_str) possible_trees = sentence_parser.parse_string_list(split_sentence) return len(possible_trees) > 0