Skip to main content

treg utilizes trie structured regex patterns to search texts for a potientially large number of words and phrases.

Project description

tregex

Tregex utilizes trie structured regex patterns to search texts for a potientially large number of words and phrases.

Documentation

Documentation is available at https://tregex.readthedocs.io/

Getting started

from treg import Tregex, Phrase, Match

# Initialize a new pattern
trex = Tregex()
# Add some phrases
trex.add_phrases([
    Phrase(phrase='afternoon tea', meta={'fun': 1}),
    Phrase(phrase='tea party', meta={'fun': 3}),
    # ...
])
# Compile the pattern
trex.compile()
# Happy searching!
for match in trex.find_iter(
        "A long collection of afternoon tea party recipes ...",
        overlapped=True):
    print(match)

# Output
Match(phrases=[Phrase(phrase='afternoon tea', meta={'fun': 1})], start=16, end=29)
Match(phrases=[Phrase(phrase='tea party', meta={'fun': 3})], start=26, end=35)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

treg-0.0.1.tar.gz (1.6 kB view hashes)

Uploaded Source

Built Distribution

treg-0.0.1-py3-none-any.whl (1.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page