Skip to main content

multi pattern match library

Project description

mpml -- Multi Pattern Match Library

mpml is a Python module that can be used to speed up the execution of a large collection of words. Forever, it can be also used to speed up the execution of a large collection of regular expressions.

There is a similiar module named esmre in github. But esmre is not a regular engine. it cannot process a simple regexp. esmre has an excellent lib named libesm. I add some function for mpml:

save to file load from file fixed match result's field: start, end now are based unicode ,nor utf8

For regular expressions, i embed sregex (https://github.com/openresty/sregex).

Here is an example:

>>> from mpml import MultiPatternMatcher, MultiRegexpMatcher
>>> index = MultiPatternMatcher()
>>> index.add_word("abc", 1)
>>> index.add_word("bc", 2)
>>> index.end()
>>> index.saveFile("1.dat")
>>> index = MultiPatternMatcher()
>>> index.loadFile("1.dat")
>>> text = "this is abc"
>>> print(index.query(text))
>>> regexp = MultiRegexpMatcher()
>>> regexp.build(["a?c", "bc"])
>>> regexp.saveFile("2.dat")
>>> regexp.loadFile("2.dat")
>>> print(regexp.query(text))
>>> 

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

mpml-1.0.1-cp37-cp37m-win_amd64.whl (195.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

mpml-1.0.1-cp37-cp37m-manylinux1_x86_64.whl (233.1 kB view hashes)

Uploaded CPython 3.7m

mpml-1.0.1-cp36-cp36m-manylinux1_x86_64.whl (230.7 kB view hashes)

Uploaded CPython 3.6m

mpml-1.0.1-cp27-cp27mu-manylinux1_x86_64.whl (136.5 kB view hashes)

Uploaded CPython 2.7mu

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