Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extract_spacy(self, text):
try:
doc = self.spacy(text)
for ent in doc.ents:
type_ = SPACY_TYPES.get(ent.label_)
label = ent.text.strip()
if type_ is not None and len(label):
entity = ExtractedEntity()
entity.text = label
entity.type = type_
entity.start = ent.start
entity.end = ent.end
yield entity
except Exception:
log.exception("spaCy failed")
def make_entity(self, text, type_, start, end):
entity = ExtractedEntity()
entity.text = text
entity.type = type_
entity.start = start
entity.end = end
return entity