Skip to main content

Fast text/token matching and replacement

Project description

Python matchtext

PyPi version Python compatibility

Python 3 package for fast text matching and replacing.

This library implements two fast approaches for matching keywords/gazetteer entries:

  • TokenMatcher: keywords/gazetteer entries are sequences of tokens, optionally associated with some data and the matcher tries to match any of those in a given sequence of tokens.
  • StringMatcher: keywords/gazetter entries are strings, optionally associated with some data and the matcher tries to match any of those in a given string, optionally only at non-word boundaries.

The matchers are implemented to be fast: TokenMatcher is a hash tree, StringMatcher uses a character trie implementation underneath. Both matchers implement additional features often required in NLP:

  • return the offsets in the original iterable where a match occurs
  • mapfunc: tokens/characters can be mapped to some canonical form that is used for matching
  • ignorefunc: some tokens/characters can be entirely ignored for matching
  • match all/longest: only match the longest entry versus all entries
  • skip/noskip: if any match is found, continue matching after the longest match versus at the next position

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

matchtext-0.2.3.tar.gz (23.8 kB view hashes)

Uploaded Source

Built Distribution

matchtext-0.2.3-py2.py3-none-any.whl (19.0 kB view hashes)

Uploaded Python 2 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