Run through python script.

Hi

I have the same need : I launch a custom ner.teach recipe using prodigy.serve('my.ner.teach') function and I move to my browser to annotate.

def ner_teach(dataset, spacy_model, source=None, label=None, patterns=None,
              exclude=None, unsegmented=False):
    logger.info("Entering ner.teach process")
    stream = source
    nlp = spacy.load(spacy_model)

    model = EntityRecognizer(nlp, label=label)

    if patterns is None:
        predict = model
        update = model.update
    else:
        matcher = PatternMatcher(nlp)
        matcher.add_patterns(patterns)

        predict, update = combine_models(model, matcher)

    if not unsegmented:
        stream = split_sentences(nlp, stream)

    stream = prefer_uncertain(predict(stream))

    return {
        'view_id': 'ner',  # Annotation interface to use
        'dataset': dataset,  # Name of dataset to save annotations
        'stream': stream,  # Incoming stream of examples
        'update': update,  # Update callback, called with batch of answers
        'exclude': exclude,  # List of dataset names to exclude
        'config': {  # Additional config settings, mostly for app UI
            'lang': nlp.lang,
            'label': ', '.join(label) if label is not None else 'all'
        }
    }

At the end, I have a No tasks available. message.

Is it possible to automate the “save to dataset” and kill the server whithout having to do the save manualy and close the server using ctrl-c in the console ?

According to this post, it seems that we could do that using a modification of the custom recipe, but I don’t know how…

After the teaching, I would like to analyse the dataset, retrain and compare with the results from last training.

Thanks