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:
@recipe('ner.annotate',
dataset=recipe_args['dataset'],
spacy_model=recipe_args['spacy_model'],
source=recipe_args['source'],
label=recipe_args['entity_label'])
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 !