Transform trie to regular expression
Efficient keyword extraction with regex
This package contains a function for efficiently representing a set of keywords as regex. This regex can be used to replace keywords in sentences or extract keywords from sentences
Why use tregex?
- Pure Python, no other dependencies
- trex is fast, about 300 times faster than a regex union, and about 2.5 times faster than FlashText
- Plays well with others, can be integrated easily with pandas
pip install tregex
import tregex as tx pattern = tx.compile(['baby', 'bat', 'bad']) hits = pattern.findall('The baby was scared by the bad bat.') # hits = ['baby', 'bat', 'bad']
Why the name?
Naming is difficult, but as we had to call it something:
- trex: trie to regex
- trex: Tyrannosaurus rex, a large dinosaur species with small arms (rex meaning "king" in Latin)
This project is based on the following resources:
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tregex-0.0.1-py3-none-any.whl (5.2 kB)||File type Wheel||Python version py3||Upload date||Hashes View|