flashtext
Extract/Replaces keywords in sentences.
What it is and what it does
FlashText is a keyword extraction and replacement library that implements a specialized algorithm optimized for finding and replacing multiple keywords in text. Instead of using regex, it builds on Aho-Corasick and Trie data structures to achieve faster performance, especially when working with large keyword dictionaries or processing many documents. The library lets you add keywords with optional clean-name mappings, extract them from text with position information, or replace them with substitutes. It also supports case-sensitive matching, custom word boundaries, and bulk keyword operations via dictionaries or lists.
The package has no external runtime dependencies and works as a pure Python implementation. However, it requires compilation during installation and has not received updates since early 2018, though the repository remains accessible. The classifiers indicate support for Python 2.7, 3.5, and 3.6, but actual compatibility with modern Python versions is unclear.
Use it for:
- Extract named entities or domain-specific terms from documents at scale faster than regex-based approaches.
- Replace product names, abbreviations, or aliases with canonical forms in bulk text processing pipelines.
- Build keyword-based text classification or tagging systems where you need to match many terms efficiently.
- Normalize variations of terms (e.g., 'Big Apple' → 'New York') across large document collections.
- Detect and extract keywords with associated metadata (e.g., category labels) from unstructured text.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts or replaces keywords in text using the FlashText algorithm, which is based on Aho-Corasick and Trie data structures and designed to be faster than regex for bulk keyword operations.
Yes, if you need fast keyword extraction or replacement on modern Python and can verify compatibility. The algorithm is sound and the library is widely used (2.5M+ monthly downloads), but the lack of updates since 2018 and high install friction (source build required) mean you should test it on your target Python version first. No known security vulnerabilities. Consider it a stable, specialized tool rather than an actively maintained package.
Install
flashtext on PyPI
pip
pip install flashtextuv
uv add flashtextpoetry
poetry add flashtextInstalling flashtext
Before you install
Installation requires building from source (high friction). The package has not been updated since February 2018, though the repository remains active with recent commits as of April 2025. Maintenance is aging but not abandoned.
License in practice
Licensed under MIT (permissive), which allows commercial and private use with minimal restrictions.
Quickstart
from flashtext import KeywordProcessor
kp = KeywordProcessor()
kp.add_keyword('Big Apple', 'New York')
kp.add_keyword('Bay Area')
keywords_found = kp.extract_keywords('I love Big Apple and Bay Area.')
# Returns: ['New York', 'Bay Area']
No runtime dependencies, but package requires building from source during installation.
Verify before relying
- Current Python 3 compatibility beyond the stated 3.5 and 3.6 support (classifiers are from 2018).
- Whether the package works reliably with modern Python versions given the age of the last release.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | aging — 3,101 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,560,496/month — #3,000 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flashtext-2.7.tar.gz
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
textsearchFind and replace multiple strings in text with…
permissive · top 15,000 on PyPI
retrieBuilds efficient Trie-based regex patterns for…
permissive · top 15,000 on PyPI
ahocorapyahocorapy implements the Aho-Corasick algorithm…
permissive · top 15,000 on PyPI
ahocorasick-rsSearches for multiple substrings in text or…
permissive · top 15,000 on PyPI
keybertKeyBERT extracts keywords and keyphrases from…
permissive · top 15,000 on PyPI
textractExtracts text from documents in multiple…
permissive · top 15,000 on PyPI
yakeYAKE extracts keywords from text documents…
copyleft · top 15,000 on PyPI
textdistanceComputes distance and similarity between text…
permissive · top 5,000 on PyPI