Edit due to off-topic
I want to use regex in SpaCy to find any combination of (Accrued or accrued or Annual or annual) leave by this code:
from spacy.matcher import Matcher
nlp = spacy.load('en_core_web_sm')
matcher = Matcher(nlp.vocab)
# Add the pattern to the matcher
matcher.add('LEAVE', None,
[{'TEXT': {"REGEX": "(Accrued|accrued|Annual|annual)"}},
{'LOWER': 'leave'}])
# Call the matcher on the doc
doc= nlp('Annual leave shall be paid at the time . An employee is to receive their annual leave payment in the normal pay cycle. Where an employee has accrued annual leave in')
matches = matcher(doc)
# Iterate over the matches
for match_id, start, end in matches:
# Get the matched span
matched_span = doc[start:end]
print('- ', matched_span.sent.text)
# returned:
- Annual leave shall be paid at the time .
- An employee is to receive their annual leave payment in the normal pay cycle.
- Where an employee has accrued annual leave in
However, I think my regex was not abstract/generalized enough to be applied to other situations, I would be very much appreciated for your advice on how to improve my regex expression with spaCy.