def where(self, si): C = self.contain_loc(si) if C: si_filtered = self.PP_location_deletion(si, C) binary_q = Binary.main(si_filtered) binary_q = binary_q[0].lower() + binary_q[1:] si_binary = binary_q if si_binary: return "where " + si_binary else: return None return None
def main(self, k): print("\n\n\n\n") print("Check Point 0") T = Tokenize.main(k, "einstein.txt") sentences_top_k = T[0] NE = T[1] questions = [] for si in sentences_top_k: print(" *** org : ", si) bin_attempt = Binary.main(si) wh_attempt = WH.main(bin_attempt, si, NE) if bin_attempt: print(" *** bin : ", bin_attempt) questions.append(bin_attempt) if wh_attempt: questions.append(wh_attempt)
def get_raw_answer(self, question, answer): q_tree = sNLP.parse(question) q_tree = Tree.fromstring(str(q_tree)) a_tree = sNLP.parse(Binary.main(answer)) a_tree = Tree.fromstring(str(a_tree)) res = True (q_top_level_structure, q_parse_by_structure) = self.get_top_level_structure(q_tree) (a_top_level_structure, a_parse_by_structure) = self.get_top_level_structure(a_tree) for i in range(0, len(q_top_level_structure)): q_label = q_top_level_structure[i] if q_label in a_top_level_structure: a_index = a_top_level_structure.index(q_label) else: print "label not found" return False # print "Result:!!!!!", self.partial_matching(q_parse_by_structure[i], a_parse_by_structure[a_index]) if not self.partial_matching(q_parse_by_structure[i], a_parse_by_structure[a_index]): # print "struct:", q_parse_by_structure[i], a_parse_by_structure[a_index] return False return True
def main(self, k): print("\n\n\n\n") binary_questions = [] print "Check Point 0" T = Tokenize.main(k) sentences_top_k = T[0] NE = T[1] # print(sentences_top_k) questions = [] for si in sentences_top_k: print(" *** org : ", si) # print(" *** original sentence: ", si) bin_attempt = Binary.main(si) wh_attempt = WH.main(bin_attempt, si, NE) if bin_attempt: print(" *** bin : ", bin_attempt) questions.append(bin_attempt) if wh_attempt: questions.append(wh_attempt) print("\n") print("\n\n\n\n")