Is there anyway that I can load a model trained in eBrevia into CoreNLP or Spacy?

134 Views Asked by At

I have a trained model for Name Entity Recognition (NER) from eBrevia. I am wondering if there is a way that I can load it into CoreNLP or Spacy using Python or Java programmatically.

Edit: If the pretrained model is a pickle model, is there a way that I can use Corenlp or Spacy to load it?

Thanks in advance!

1

There are 1 best solutions below

1
On

With spaCy (Python), you should be able to write a custom component and within that, implement a wrapper around your current NER model. Custom components always take a doc as input, modify it, and return it. This allows chaining of both custom as well as "pre-fab" components.

For instance, if your NER model takes a list of tokens as input, and returns a list of their BILUO tags, you could wrap that model as such:

from spacy.gold import offsets_from_biluo_tags

def custom_ner_wrapper(doc):
    words = [token.text for token in doc]
    custom_entities = your_custom_ner_model(words)    
    doc.ents = spans_from_biluo_tags(doc, custom_entities)    
    return doc

Once you have defined that custom pipeline component called custom_ner_wrapper, you have to add it to your nlp pipeline like so:

nlp.add_pipe(custom_ner_wrapper)

More information can be found here: https://spacy.io/usage/processing-pipelines#wrapping-models-libraries