def do_acomp(self): edges = find_edges(self, lambda((u, v)):self.edge_label((u, v)) == "acomp" and u.isPredicate) for predNode,acompNode in edges: neighbors = predNode.neighbors() subjs = multi_get(neighbors,subject_dependencies) if len(subjs)!=1: # self.types.add("debug") pass else: if (predNode.text[0].word in self.modalVerbs) or (predNode.features.get("Lemma","") in self.modalVerbs): subj = subjs[0] self.del_edge((predNode,acompNode)) self.add_edge((acompNode,subj),label=domain_label) acompNode.isPredicate=True self.del_edge((predNode,subj)) duplicate_all_incidents(gr=self, source=predNode, target=acompNode) self.add_edge((acompNode,predNode),label=SOURCE_LABEL) if (len(self.neighbors(predNode))==0) and (len(predNode.text)==1) and (predNode.text[0].word in contractions): self.del_node(predNode) else: self.types.add("acomp_as_modal") else: self.types.add("acomp_as_mwe") merge_nodes(gr=self, node1=predNode, node2=acompNode)
def do_acomp(self): edges = find_edges( self, lambda ((u, v)): self.edge_label( (u, v)) == "acomp" and u.isPredicate) for predNode, acompNode in edges: neighbors = predNode.neighbors() subjs = multi_get(neighbors, subject_dependencies) if len(subjs) != 1: # self.types.add("debug") pass else: if (predNode.text[0].word in self.modalVerbs) or (predNode.features.get( "Lemma", "") in self.modalVerbs): subj = subjs[0] self.del_edge((predNode, acompNode)) self.add_edge((acompNode, subj), label=domain_label) acompNode.isPredicate = True self.del_edge((predNode, subj)) duplicate_all_incidents(gr=self, source=predNode, target=acompNode) self.add_edge((acompNode, predNode), label=SOURCE_LABEL) if (len(self.neighbors(predNode)) == 0) and (len( predNode.text) == 1) and (predNode.text[0].word in contractions): self.del_node(predNode) else: self.types.add("acomp_as_modal") else: self.types.add("acomp_as_mwe") merge_nodes(gr=self, node1=predNode, node2=acompNode)
def _merge(self): edges = find_edges(self, lambda (u,v):(self.edge_label((u,v)) in join_labels) or (self.edge_label((u,v))=="conj_and" and u.features.get("conjType",[""])[0]=='&')) for u, v in edges: conjType = u.features.get("conjType",False) if conjType: conjType = conjType[0] #only the words matching = [w for w in u.surface_form if w.word == conjType] if matching: w = matching[0] else: w = Word(index = u.maxIndex()+1,word=conjType) u.text.append(w) merge_nodes(self, u, v) return True return False