def match_pattern(tree): adjective = pt.find_node(tree, pt.match_POS("JJ")) name = pt.find_node(adjective, pt.match_POS("NN", "NNP")) if name and adjective: return {"name": name, "adjective": adjective, "negation": adjective.is_negated()} else: return None
def match_pattern(tree): if not tree.is_question(): return None adjective = pt.find_node(tree, pt.match_POS("JJ")) who = pt.find_node(adjective, pt.match_word("who")) if who: return {"adjective": adjective} return None
def match_pattern1(tree): if not tree.is_question(): return None name = pt.find_node(tree, pt.match_POS("NNP")) wh_pronoun = pt.find_node(tree, pt.match_POS("WP")) if name and wh_pronoun: return {"name": name, "negative_response": None} return None
def match_pattern(tree): if tree.is_question(): return None verb = pt.find_node(tree, pt.match_POS("VB", "VBD", "VBG", "VBN", "VBP", "VBZ")) subject_tree = pt.find_node(verb, pt.match_gram("nsubj")) object_tree = pt.find_node(verb, pt.match_gram("dobj")) if verb and subject_tree: return {"verb_tree": verb, "subject_tree": subject_tree, "object_tree": object_tree} return None
def match_pattern(tree): if not tree.is_question(): return None person = pt.find_node(tree, pt.match_POS("NNP")) copular = pt.find_node(person, pt.match_gram("cop")) adjective = pt.find_node(person, pt.match_POS("JJ")) if copular and adjective: return {"person": person, "adjective": adjective} return None
def match_pattern(tree): if tree.is_question(): return None super_noun = pt.find_node(tree, pt.match_POS("NN", "NNS")) copular = pt.find_node(super_noun, pt.match_gram("cop")) sub_noun = pt.find_child_node(super_noun, pt.match_POS("NN", "NNS", "NNP")) if sub_noun and copular: return {"super_noun": super_noun, "sub_noun": sub_noun} return None
def match_pattern(tree): if not tree.is_question(): return None verb_tree = pt.find_node(tree, pt.match_POS("VB", "VBD", "VBG", "VBN", "VBP", "VBZ")) copular = pt.find_node(verb_tree, pt.match_word("are", "is")) subject_tree = pt.find_node(verb_tree, pt.match_gram("nsubj")) object_tree = pt.find_node(verb_tree, pt.match_gram("dobj")) if copular and verb_tree and subject_tree: return {"verb_tree": verb_tree, "subject_tree": subject_tree, "object_tree": object_tree} return None
def match_pattern(tree): greeting = pt.find_node(tree, pt.match_word("hi", "hello", "greetings", "howdy")) if greeting: return {"greeting": greeting.word} return None
def match_pattern2(tree): tell = pt.find_node(tree, pt.match_word("tell")) person = pt.find_node(tell, pt.match_POS("NNP")) about = pt.find_node(person, pt.match_word("about")) if about: return {"name": person, "negative_response": "Who is that?"}