Is it possible to support quantifier (n,m) for rule matching?
See original GitHub issue! | Negate the pattern, by requiring it to match exactly 0 times.
-- | --
? | Make the pattern optional, by allowing it to match 0 or 1 times.
+ | Require the pattern to match 1 or more times.
* | Allow the pattern to match zero or mo
In addition to the operators above, is it possible to support the {n,m} quantifier in the rule matcher? Or least {n} times. The reason is that, for linear matching, there is often a need to restrict how far two tokens occur in a piece of text. The shorter the distance, the more reliable the pattern. For example:
pattern = [{"LOWER": "hello"},
{"LOWER": "world"}]
For this pattern, I want to add an additional condition to require that the two words ‘hello’ and ‘world’ will be within a distance of no more than 12 words. Is there a way to express this logic for the current matcher? If not, how likely this can be supported by introducing the RE quantifier {n,m}? This is very useful for pattern matching in practical applications.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Regex exactly n OR m times - Stack Overflow
There is no single quantifier that means "exactly m or n times". The way you are doing it is fine. An alternative is:...
Read more >Quantifiers in Regular Expressions - Microsoft Learn
The quantities n and m are integer constants. Ordinarily, quantifiers are greedy. They cause the regular expression engine to match as many ...
Read more >Regex Quantifier Tutorial: Greedy, Lazy, Possessive - RexEgg
It is "one or more, but as many as possible (greedy), and giving back characters if needed in order to allow the rest...
Read more >Quantifiers +, *, ? and {n} - The Modern JavaScript Tutorial
A quantifier is appended to a character (or a character class, or a [...] set etc) and specifies how many we need. \d{5}...
Read more >Quantifiers - JavaScript - MDN Web Docs - Mozilla
By default quantifiers like * and + are "greedy", meaning that they try to match as much of the string as possible. The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi! The matcher code can be found here: https://github.com/explosion/spaCy/blob/master/spacy/matcher/matcher.pyx
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.