# Patterns and custom NER

**URL:** <https://support.prodi.gy/t/patterns-and-custom-ner/163>\
**Category:** Uncategorized\
**Tags:** usage, ner\
**Created:** [December 27, 2017, 1:29am UTC](https://support.prodi.gy/t/patterns-and-custom-ner/163 "2017-12-27T01:29:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rkeyvani](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@rkeyvani](https://support.prodi.gy/u/rkeyvani)\
**Post date:** [December 27, 2017, 1:29am UTC](https://support.prodi.gy/t/patterns-and-custom-ner/163/1 "2017-12-27T01:29:59Z")

</div>

Hello,  
I want to create by Own LABEL for named entity extraction, I have a set of terms for example “surcharge”, “tax”, “tax liability”  
Just want to be clear on the steps:

1- Create a Database Mydatabase  
2- Create a Jsonl file with records {“label”:“MYLABEL”,“pattern”:[{“lower”:“surcharge”}]}  
3- call ner.teach Mydatabase en\_core\_web\_lg trainingfile.txt --label MYLABEL --patterns myjson.jsonl

couple of questions

1. where can I find a complete list of patterns in documentation is this in spacy or prodigy docs?
2. If I want MYLABEL to tag two consecutive words together “limited liability” a ngram of size two can I chain patterns?  
3)Since I am not building a --seed set rather using a set of predefined discrete words based on patterns do I need en\_core\_web\_lg, I see you use this only in the context of expanding the seed set

---

<div class="post-metadata">

**Author:** ![ines](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ines/32/3_2.png) [@ines](https://support.prodi.gy/u/ines)\
**Post date:** [December 27, 2017, 12:25pm UTC](https://support.prodi.gy/t/patterns-and-custom-ner/163/2 "2017-12-27T12:25:40Z")

</div>

Sorry for the delayed response – answers below! Your workflow looks good and all correct btw.

> [@rkeyvani](#):
>
> where can I find a complete list of patterns in documentation is this in spacy or prodigy docs?

Yes, you can find examples of the JSONL format in the "Input formats" section of the Prodigy README: `PRODIGY_README.html#match-patterns`. Since the `"patterns"` key can have the same format as spaCy's match patterns, you can also check out the spaCy docs on [rule-based matching](https://spacy.io/usage/linguistic-features#rule-based-matching) for more examples. Keep in mind that all spaCy examples are written in Python, so you'll obviously have to convert them to JSON first (double quotes, lowercase `true` and `false` etc).

> [@rkeyvani](#):
>
> If I want MYLABEL to tag two consecutive words together “limited liability” a ngram of size two can I chain patterns?

A pattern is a list of dictionaries where one dictionary describes one token. So to match "limited liability", your pattern entry could look like this:

```json
{"label": "MYLABEL", "pattern": [{"lower": "limited"}, {"lower": "liability"}]}

```

This will match "limited liability", "Limited Liability", "LiMiTeD LiAbIlItY" etc. You can also use `"orth"` to match on exact strings instead of the lowercase form, or use other token attributes like `is_punct` or the token's `shape`.

> [@rkeyvani](#):
>
> Since I am not building a --seed set rather using a set of predefined discrete words based on patterns do I need en\_core\_web\_lg, I see you use this only in the context of expanding the seed set

Yes, in the example, we mostly use the `lg` model because it includes more word vectors for bootstrapping. If you don't use this step, you can also choose a different model. Especially for the first experiments, it's often easier to use the `sm` models, as they load and serialize faster.
