def markNamedEntities(self, entityElements): """ Marks tokens belonging to named entities """ namedEntityTokens = [] for entityElement in entityElements: offsets = [] offsetStrings = entityElement.attrib["charOffset"].split(",") for offsetString in offsetStrings: charFrom, charTo = offsetString.split("-") offset = (int(charFrom), int(charTo)) offsets.append(offset) for k, v in self.tokensById.iteritems(): for offset in offsets: if Range.overlap(offset, v.charOffset): v.entities.append(entityElement.attrib["id"]) namedEntityTokens.append(v.id) return namedEntityTokens
def markNamedEntities(self, entityElements): """ Marks tokens belonging to named entities """ namedEntityTokens = [] for entityElement in entityElements: offsets = [] offsetStrings = entityElement.attrib["charOffset"].split(",") for offsetString in offsetStrings: charFrom, charTo = offsetString.split("-") offset = (int(charFrom), int(charTo)) offsets.append(offset) for k,v in self.tokensById.iteritems(): for offset in offsets: if Range.overlap(offset, v.charOffset): v.entities.append(entityElement.attrib["id"]) namedEntityTokens.append(v.id) return namedEntityTokens
def markBioInferInteractions(self, interactions): """ Marks tokens belonging to a BioInfer interaction """ interactionTokens = [] for interaction in interactions: offsets = [] offsetStrings = interaction[3].split(",") for offsetString in offsetStrings: charFrom, charTo = offsetString.split("-") offset = (int(charFrom), int(charTo)) offsets.append(offset) for k, v in self.tokensById.iteritems(): for offset in offsets: if Range.overlap(offset, v.charOffset): v.interactionWords.append(interaction[4]) interactionTokens.append(v.id) return interactionTokens
def markBioInferInteractions(self, interactions): """ Marks tokens belonging to a BioInfer interaction """ interactionTokens = [] for interaction in interactions: offsets = [] offsetStrings = interaction[3].split(",") for offsetString in offsetStrings: charFrom, charTo = offsetString.split("-") offset = (int(charFrom), int(charTo)) offsets.append(offset) for k,v in self.tokensById.iteritems(): for offset in offsets: if Range.overlap(offset, v.charOffset): v.interactionWords.append(interaction[4]) interactionTokens.append(v.id) return interactionTokens