ngram
A `set` subclass providing fuzzy search based on N-grams.
Decision gist · record as of 2026-08-14
Yes, if you need lightweight fuzzy string matching in a standalone Python project and can accept that the package is no longer maintained. The library is stable, has no dependencies, and works with current Python versions. However, do not adopt it for security-sensitive applications or if you require ongoing maintenance and updates.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low install friction with no runtime dependencies.
- However, the package is abandoned—last commit was 2021-09-15, over 1794 days ago.
- While marked Production/Stable and supporting current Python versions, no active maintenance means security or compatibility issues will not be addressed.
License · maintenance · safety
LGPL3 (copyleft) — Licensed under LGPLv3 (copyleft). You may use and modify the package freely, but any derivative work must also be released under a compatible copyleft license. Proprietary or closed-source projects should review copyleft obligations before adopting.
last release 2021-09-15 (1794 days) · last repo commit 2021-09-15 · 118 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 180,831 downloads/mo, #10,139 on PyPI
Alternatives
Verify before relying
pip install ngram
from ngram import NGram
ng = NGram(items=['apple', 'application', 'apply'])
results = ng.search('aple')- Whether the package handles Unicode or non-ASCII strings correctly in modern Python environments.
- Performance characteristics on large datasets or with very long strings.
- Compatibility with recent Python minor versions despite the 'supports_current' classification.
What it is and what it does
NGram is a Python set subclass that indexes items by their character-based N-gram representation (default N=3), enabling fuzzy search by string similarity. When you add items to an NGram set, it pads each item's string representation, splits it into overlapping N-character substrings, and stores associations between those N-grams and the items. To find similar items, you query with a string, and the class ranks results by the ratio of shared to unshared N-grams, returning matches even when the query doesn't exactly match any stored item.
The package is designed for non-string items too—you provide a key function (like `str`) to extract or normalize the string representation before indexing. It does not implement a language model; it is purely a character-level similarity index. The library has been in production use since 2007 but is no longer actively maintained, with the last release in 2021-09-15.
Use it for
- Implement a typo-tolerant search in a dataset where exact matches fail but similar strings should be found.
- Build a duplicate-detection system that identifies near-duplicate strings by N-gram overlap.
- Create a spell-checker or autocorrect feature that ranks candidate corrections by string similarity.
- Index and search user-provided text where minor spelling variations are common.
- Perform fuzzy matching between datasets to link records that refer to the same entity with slightly different names.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need lightweight fuzzy string matching in a standalone Python project and can accept that the package is no longer maintained.
The library is stable, has no dependencies, and works with current Python versions. However, do not adopt it for security-sensitive applications or if you require ongoing maintenance and updates.
Install
ngram on PyPI
Before you install
Low install friction with no runtime dependencies. However, the package is abandoned—last commit was 2021-09-15, over 1794 days ago. While marked Production/Stable and supporting current Python versions, no active maintenance means security or compatibility issues will not be addressed.
License in practice
Licensed under LGPLv3 (copyleft). You may use and modify the package freely, but any derivative work must also be released under a compatible copyleft license. Proprietary or closed-source projects should review copyleft obligations before adopting.
Quickstart
pip install ngram
from ngram import NGram
ng = NGram(items=['apple', 'application', 'apply'])
results = ng.search('aple')
Verify before relying
- Whether the package handles Unicode or non-ASCII strings correctly in modern Python environments.
- Performance characteristics on large datasets or with very long strings.
- Compatibility with recent Python minor versions despite the 'supports_current' classification.
Package facts
| License | LGPL3 copyleft |
| Python support | Supports the current Python release >=3.0 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | None |
| Maintenance | Abandoned 1,794 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 180,831 / month, #10,139 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)Natural Language :: EnglishOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Topic :: Text ProcessingTopic :: Text Processing :: IndexingTopic :: Text Processing :: Linguistic |
Evidence: ngram-4.0.3-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “n-gram similarity search”
- ngramExtends Python's set class to perform fuzzy string matching using…
- strsimpyImplements a dozen string similarity and distance algorithms…
- textacytextacy extends spaCy's NLP capabilities with pre- and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Text Processing packages
A drop-in replacement for Python's standard `re` module that adds advanced regex features like nested sets, fuzzy matching, lookaround in conditionals, and full Unicode case-folding while maintaining backward compatibility.
pyparsing provides a library for building text parsers directly in Python code using composable grammar classes, handling quoted strings, whitespace variation, and embedded comments without regex or lex/yacc.
Install it if you need to parse text or define grammars programmatically.
fonttools manipulates font files in multiple formats (TrueType, OpenType, AFM, Type 1, Mac-specific) and includes TTX, a tool to convert fonts to and from XML text format.
Install it if you need to read, write, or manipulate fonts programmatically or via the TTX command-line tool.
Docutils converts plaintext documentation in reStructuredText format into multiple output formats including HTML, XML, and LaTeX using a modular processing system.
RapidFuzz provides fast fuzzy string matching using Levenshtein Distance and related metrics, implemented mostly in C++ with Python bindings for rapid similarity scoring and approximate string matching.
Install it if you need fuzzy string matching; it's a solid replacement for FuzzyWuzzy with better licensing and performance.
tinycss2 parses CSS strings into token and block objects, and generates CSS strings from those objects, following the CSS Syntax Level 3 specification without enforcing specific properties or values.
Install it if your project requires CSS tokenization or syntax manipulation.
See also fuzzyset2 · pysimstring · fuzzysearch · strsimpy · tfidf-matcher · thefuzz · fuzzywuzzy · string-grouper · ppdeep · py-tlsh