how to add --pattern to ner manual

python -m prodigy ner.manual mysourse blank:en ./newresults.jsonl --label labEL1,label2,lable3 --patterns pref_my_patterns_textcat.jsonl -F customprodigy.py 

I need to add the patterns that would be highlighted. The default ner.manual prodigy-recipes/ner_manual.py at master · explosion/prodigy-recipes · GitHub does not give options to higlight the patterns.?

Hi @deepesh, what happens if you run the command above? Does it pre-highlight the entities with your pattern?

If you're using a Prodigy version >= 1.9, then the --patterns command should exist. If you're incorporating this in a custom recipe, you can use a PatternMatcher and include it in the stream, something like this:

from prodigy.models.matcher import PatternMatcher


# Inside the recipe
...
stream = JSONL(...)

if patterns is not None:
    matcher = PatternMatcher(nlp, combine_matches=True, all_examples=True)
    matcher = pattern_matcher.from_disk("path/to/patterns.jsonl")
    stream = (eg for _, eg in pattern_matcher(stream))

stream = add_tokens(...)

nlp = spacy.load(spacy_model)

stream = JSONL(source)

if patterns is not None:
    matcher = PatternMatcher(nlp, combine_matches=True, all_examples=True)
    matcher = matcher.from_disk("_patterns_textcat.jsonl")
    stream = (eg for _, eg in matcher(stream))

It is working. thank you

How to highlight patterns in different colors based on pattern label ?

You can set a custom theme and customize the label colors based on a hex code.

My question is i would like to highlight the pattern that is loaded using PatternMatcher with different color . I can customize the label color but not the pattern highlights that would load.