Changelog¶
All notable changes to this project are documented here. The format follows Keep a Changelog and the project uses Semantic Versioning.
[Unreleased]¶
1.0.0 - 2026-11-24¶
The first stable release. The public API is now covered by Semantic Versioning: no breaking changes until 2.0. This release removes the compatibility layer kept for the 0.0.2 API.
Removed¶
The 0.0.2 compatibility aliases. Each one has a direct replacement:
| Removed | Use instead |
|---|---|
keylex.matchers.keyword, keylex.matchers.keyword_list modules |
from keylex import Keyword, Term, KeywordList |
keylex.matchers.Matcher |
keylex.BaseMatcher |
KeywordMatcher(..., fuzzy_algo=...) and matcher.fuzzy_algo |
scorer= / matcher.scorer |
Keyword.keyword |
Keyword.name |
KeywordList.add_keyword(kw) |
KeywordList.add(kw) |
KeywordList.remove_keyword(kw) |
KeywordList.discard(kw) (or remove, which raises if missing) |
KeywordList.get_keyword(name) |
KeywordList.get(name) |
KeywordList.get_all_keywords() |
KeywordList.names |
KeywordList.get_index(name) |
KeywordList.names.index(name) |
KeywordList.get_keywords_and_related_terms() |
{kw.name: kw.related_terms for kw in keyword_list} |
Changed¶
Keyword.has_related_termsis a property, likehas_synonymsandhas_acronyms(drop the()).thresholdis now the last positional argument ofKeywordMatcher; every later option is keyword-only.- Every public method, property and rule helper has a docstring, so editors show help on hover and the API reference documents every member.
Rule.test()is typed to take a matcher (BaseMatcher).
Fixed¶
- Loading a keyword file with invalid JSON (including JSON inside a CSV field) raised an unrelated
TypeError, and invalid YAML raised a bareyaml.YAMLError. Both now raiseValueErrornaming the file.
0.1.0 - 2026-11-20¶
A rewrite of the matching core plus four new subsystems: rules, keyword extraction, spaCy
integration and a CLI. Over 700 tests (including every README example), mypy --strict clean,
CI on Linux, macOS and Windows with Python 3.10-3.14.
Added¶
Matchobjects: every result carries the canonical keyword, the exact surface text and its offsets into the original text, which term matched (term,kind),method,score,categoryand theKeyworditself.Termobjects with per-termcase_sensitive,fuzzyandwhole_wordoptions. Acronyms and all-caps terms are case-sensitive by default (acronym_case="strict" | "title" | "ignore"), andUSalso matchesU.S..- Richer
Keyword:variants, regexpatterns, context rules (exclude/requirewithincontext_windowwords, scoped to the sentence by default),category,tags,weightandmetadata. - Windowed fuzzy matching: typo-tolerant and multi-word, with exact offsets, every occurrence,
any RapidFuzz scorer and a length guard for short terms. Windows never cross sentence or clause
boundaries.
keylex[fast](numpy) batches the scoring over all cores. - Rule engine (
keylex.rules): AND/OR/NOT,NEAR/BEFORE,ATLEAST,ANY(n, ...),SENTENCE/PARAGRAPH,CATEGORY,TAG; a readable rule language (parse_rule,to_dsl()round-trips), named weighted rules (RuleEngine),explain(),validate()/diagnostics()and JSON/YAML rule files. - Keyword extraction without a keyword list (
extract_keywords): YAKE, RAKE, TextRank and TF-IDF in pure Python, with MMR diversity, near-duplicate merging, stopword lists foren,de,fr,es,itandel, and an optional spaCy POS filter. Extracted phrases are always real surface forms of the text. - spaCy integration:
nlp.add_pipe("keylex"),add_to_pipeline()and EntityRuler pattern export. Keywords are saved with the pipeline, and processed docs serialise (DocBin,nlp.pipe(n_process=...)). - CLI:
keylex match | extract | ruleswith text, JSON and JSONL output, highlighting,rules --check,--fail-on/--min-scoreCI gates and exit codes 0 (found) / 1 (nothing) / 2 (error). - Overlap strategies (
longest,leftmost,all), a light plural stemmer or any custom stemmer, accent folding, NFKC normalisation with offsets mapped back to the original text, and highlighting (brackets, ANSI, HTML, Markdown, templates, callables; HTML-escaped). KeywordList:rename,filter,categories,find_conflicts,on_duplicatepolicies and lossless JSON / CSV / YAML / TXT load and save (atomic writes, BOM detection).KeywordMatcher.configure()/options(); options can also be changed by assignment and are picked up on the next call. Matchers are thread-safe and picklable.- Output formats
matches,categoriesandscore, with precise@overloadtypes for every format;match_many,contains,count,score. - Benchmarks (
benchmarks/bench_exact.py), a release workflow with PyPI trusted publishing, and pre-commit hooks.
Changed¶
KeywordMatcher.match()returnslist[Match]by default.output="detailed"returns dicts withstart/endkeys (previouslystart_pos/end_pos).Keyword.keywordis read-only (useKeywordList.rename).Keywordobjects are unhashable because they are mutable; usekeyword.nameas a dict key.- Exact matching is a single pass over the text with a token trie: matching time no longer grows with the vocabulary (100,000 keywords over a 20,000-word text in about 20 ms).
fuzzy_algo=is deprecated in favour ofscorer=. The default fuzzy threshold is 85 with theratioscorer.- Python 3.10+ (the
<3.13cap was removed);rapidfuzz>=3,<4instead of an exact pin.
Fixed¶
to_dict()/to_json()output can now be loaded back (it used to corrupt every keyword).- Fuzzy matching only found exact substrings, and only the first occurrence.
output="count"counted substrings of keyword names instead of matches.- Acronyms matched case-insensitively (
USmatched "us"). - Empty keywords matched everywhere; strings passed to
add_synonymswere split into characters. - Terms such as
C++,C#and.NETnever matched. remove_keywordcrashed; renaming a keyword corrupted the list; duplicate adds silently lost data;mergeshared objects between lists.- Duplicate and overlapping matches,
OutputFormatenum values rejected, options not validated, non-deterministic output order,<=/>on keywords, whitespace and hyphen variation.
Removed¶
- The empty top-level
extractors/package,tox.iniand the empty requirements files.
0.0.2¶
- Initial
Keyword,KeywordListandKeywordMatcher.