Implementing Advanced Pattern Matching Techniques with the 'esmre' Class Library
pip install esmre
python
from esm import ESM
python
esm = ESM()
python
esm.idx("apple", "fruit")
esm.idx("banana", "fruit")
esm.idx("car", "vehicle")
python
matches = esm.search("I like to eat an apple and drive a car.")
python
for match in matches:
start, end, pattern_id = match
print(f"Match: {text[start:end]} - Pattern ID: {pattern_id}")