NER automatically update patterns

hi @bev.manz!

Thanks for your question.

Yes, check out this post:

Key is using update callback to add new spans as patterns:

def update(answers):
    patterns = set()
    for eg in answers:
        for span in eg.get("spans", []):
            # Get the text of each annotated span given its offsets
            span_text = eg["text"][span["start"]:span["end"]]
            patterns.add({"pattern": span_text, "label": span["label"]})
    matcher.add_patterns(patterns)

There are a few more recent posts that build off of this idea: