class Example(PatternsGrammar):
single_unit = lower('meters') | lower('second') | lower('kilometers') | lower('hour')
compound_unit = single_unit + lower('per') + single_unit
UNIT = single_unit | compound_unit
QUANTITY = pos('NUM') + UNITIn this text:
The car is traveling at a speed of 108 kilometers per hour. Represent this speed in meters per second.
These entities wil be recognized:
108 kilometers per hour-QUANTITY.meters per second-UNIT.
https://pypi.org/project/spacy-pat-match-dsl/
- Allows for easier constructing and extending of rule-based NER (Named Entity Recognition) systems.
- Supports many common modifiers such as:
lower(lowercase form),pos(part-of-speech),lemma(lemmatized word). - You can also generate BNF (Backus-Naur form) of the patterns for use in documentation or scientific papers.
This project is a library, intended to used in other projects.
See the example script for details on usage.
Also see documentation in the source code for all capabilities of this project.
This project is inspired by lrparsing.
- Patterns are represented via special classes.
- These classes have method
generate_patternswhich generatesspaCy-native datastructre for NER patterns. PatternGrammarreads its own static variables and collects all the patterns.