def add_relation(self, entity1, entity2, subtype, source="goldstandard", **kwargs): if self.pairs.pairs: pid = self.sid + ".p" + str(len(self.pairs.pairs)) else: pid = self.sid + ".p0" if subtype == "tlink": p = TLink(entity1, entity2, original_id=kwargs.get("original_id"), did=self.did, pid=pid, rtype=subtype) else: p = Pair((entity1, entity2), subtype, pid=pid, sid=self.sid, did=self.did) self.pairs.add_pair(p, source) return p
def add_relation(self, entity1, entity2, subtype, relation, source="goldstandard", **kwargs): if self.pairs.pairs: pid = self.did + ".p" + str(len(self.pairs.pairs)) else: pid = self.did + ".p0" between_text = self.text[entity1.dend:entity2.start] logging.info("adding {}:{}=>{}".format(pid, entity1.text.encode("utf8"), entity2.text.encode("utf8"))) # print between_text if subtype == "tlink": pair = TLink(entity1, entity2, relation=relation, original_id=kwargs.get("original_id"), did=self.did, pid=pid, rtype=subtype, between_text=between_text) else: pair = Pair((entity1, entity2), subtype, did=self.did, pid=pid, original_id=kwargs.get("original_id"), between_text=between_text) self.pairs.add_pair(pair, source) return pair