Using ner.manual with predict

I’m currently trying to adapt a NER from Spacy to a specific domain and i’d like to use the ner.manual viewId in order to annotate my documents. But I’d like to have the model prediction in this view, i tried to create my own recipe with predict(stream) but the view doesn’t support this kind of data i guess.

I tried to look at how i could edit this view id (ner.manual) but couldn’t find this information.

Here is my recipe tryout:

def annotate(dataset, spacy_model, source, label=[]):
    stream = get_stream(source, rehash=True, dedup=True, input_key='text')
    # Create the model, using a pre-trained spaCy model.
    nlp = spacy.load(spacy_model)
    labels = get_labels(label, nlp)
    model = EntityRecognizer(nlp, label=label)
    predict = model
    update = model.update
    # Split the stream into sentences
    stream = split_sentences(nlp, stream)
    # Return components, to construct Controller
    return {
        'view_id': 'ner.manual',
        'dataset': dataset,
        'stream': predict(stream),
        'update': update,  # callback to update the model in-place
        'config': {'lang': model.nlp.lang,
                   'labels': labels}

Thanks in advance for your help !

Looks like there’s a small typo in your view_id – it’s ner_manual, not ner.manual (which is the name of the recipe).

Also, just so you know, the manual NER interface currently doesn’t support pre-defined spans and will only let you annotate from scratch. This means that your recipe will work and show examples from the scored stream, but it’ll reset all "spans" in the interface.

Correcting pre-defined spans in the manual NER interface will be coming to Prodigy in the next version, as a new and improved ner.make-gold recipe. See my comments on this thread for more details.

1 Like