Socket
Socket
Sign inDemoInstall

tregex

Package Overview
Dependencies
0
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tregex

Transform trie to regular expression


Maintainers
1

Readme

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

Build Status codecov

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

Install trex

Use pip,

pip install tregex

Usage

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)

Acknowledgments

This project is based on the following resources:

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc