Unable to identify organisations

#1
by akshatjaimini - opened

Hii, so I was using your implementation to anonymize Organisations and People in a given text but its not able to identify organisations.
I am using the following with the CustomSpacyRecognizer but this doesn't seem to work.

def identify_entities(text):
    entities = ["ORGANIZATION", "PHONE_NUMBER", "PERSON"]
    spacy_recognizer = CustomSpacyRecognizer()

    configuration = {
        "nlp_engine_name": "spacy",
        "models": [
            {"lang_code": "en", "model_name": "en_spacy_pii_distilbert"}],
    }

    # Create NLP engine based on configuration
    provider = NlpEngineProvider(nlp_configuration=configuration)
    nlp_engine = provider.create_engine()

    registry = RecognizerRegistry()
    # add rule-based recognizers
    registry.load_predefined_recognizers(nlp_engine=nlp_engine)
    registry.add_recognizer(spacy_recognizer)
    # remove the nlp engine we passed, to use custom label mappings
    registry.remove_recognizer("SpacyRecognizer")

    analyzer = AnalyzerEngine(nlp_engine=nlp_engine,
                              registry=registry, supported_languages=["en"])
    print(analyzer.get_supported_entities())

    entities = analyzer.analyze(text=text, language="en", entities=entities)
    return entities

Although it is giving the right results on the hugging face demo

Sign up or log in to comment