def dep_ccomp(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): target_token = token.head library.make_mono_predicate(token, predicates) if not library.add_to_obj_list(token, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, None, token)
def dep_pcomp(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): prep_token = token.head prep_head = prep_token.head if prep_head.dep_ is "xcomp": prep_head = library.until_not("xcomp", prep_head) if library.get_predicate(prep_token, predicates) is None: library.make_mono_predicate(token, predicates) library.make_predicate(predicates, prep_token, prep_head, token)
def dep_dobj(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): target_token = token.head if target_token.dep_ is "xcomp": target_token = library.until_not("xcomp", target_token) if not library.add_to_obj_list(token, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, None, token) library.make_mono_predicate(token, predicates)
def dep_modifier(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): if not library.get_predicate(token, predicates): target_token = token.head if target_token.dep_ in dep_modifiers: while target_token.dep_ in dep_modifiers: target_token = target_token.head elif target_token.dep_ is "xcomp": target_token = library.until_not("xcomp", target_token) library.make_mono_predicate(target_token, predicates) library.make_predicate(predicates, token, target_token)
def dep_nsubj(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): target_token = token.head if target_token.dep_ is not "parataxis": if target_token.dep_ is "ccomp": if not library.add_to_subj_list(token, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, token) elif target_token.dep_ is "relcl": if not library.add_to_subj_list(target_token.head, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, target_token.head) else: if not library.add_to_subj_list(token, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, token) library.make_mono_predicate(token, predicates)
def dep_pobj(token, variables, predicates, cond_tokens, passive_tokens, num_of_terms, isa_tokens): if token.dep_ is "conj": pobj_token = library.until_not("conj", token) prep_token = pobj_token.head else: prep_token = token.head if prep_token.dep_ is "prt": target_token = prep_token.head if target_token.dep_ is "xcomp": target_token = library.until_not("xcomp", target_token) if not library.add_to_obj_list(token, target_token, variables, predicates, num_of_terms): library.make_predicate(predicates, target_token, target_token, None, token) library.make_mono_predicate(token, predicates) else: if prep_token.dep_ is "conj": prep_head = library.until_not("conj", prep_token) prep_head = prep_head.head else: prep_head = prep_token.head if prep_head.dep_ is "appos": prep_head = library.until_not("appos", prep_head) elif prep_head.dep_ is "xcomp": prep_head = library.until_not("xcomp", prep_head) #elif prep_head.dep_ is "conj": # prep_head = library.until_not("conj", prep_head) if prep_token.dep_ is "agent": library.add_to_subj_list(token, prep_head, variables, predicates, num_of_terms) while prep_head.dep_ is "conj" and prep_head.head in passive_tokens: library.add_to_subj_list(token, prep_head.head, variables, predicates, num_of_terms) prep_head = prep_head.head elif library.get_predicate(prep_token, predicates) is None: library.make_mono_predicate(token, predicates) library.make_mono_predicate(prep_head, predicates) library.make_predicate(predicates, prep_token, prep_head, token)