PhraseMatcher and EntityRuler

Let's learn how spaCy help us with matching long dictionaries.

We'll cover the following


While processing financial, medical, or legal text, often we have long lists and dictionaries, and we want to scan the text against our lists. As we saw in the previous section, Matcher patterns are quite handcrafted; we coded each token individually. If we have a long list of phrases, Matcher is not very handy. It's not possible to code all the terms one by one.

spaCy offers a solution for comparing text against long dictionaries—the PhraseMatcher class. The PhraseMatcher class helps us match long dictionaries. Let's get started with an example:

Get hands-on with 1200+ tech skills courses.