Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def analyze(self, text, entities, nlp_artifacts=None):
results = []
if not nlp_artifacts:
self.logger.warning(
"Skipping SpaCy, nlp artifacts not provided...")
return results
ner_entities = nlp_artifacts.entities
for entity in entities:
if entity in self.supported_entities:
for ent in ner_entities:
if SpacyRecognizer.__check_label(entity, ent.label_):
explanation = SpacyRecognizer.build_spacy_explanation(
self.__class__.__name__,
NER_STRENGTH,
ent.label_)
spacy_result = RecognizerResult(
entity, ent.start_char,
ent.end_char, NER_STRENGTH, explanation)
results.append(spacy_result)
return results