Skip to main content

LexNeedle

LexNeedle is a deterministic, Unicode-aware dictionary matcher for Python 3.12+, with zero runtime dependencies. Use it when exact terms, trustworthy original-text offsets, and predictable overlap handling matter.

Install

uv add lexneedle

For the unreleased main branch:

uv add "git+https://github.com/crootman/LexNeedle"

Quick start

from lexneedle import Matcher

matcher = Matcher()
matcher.add("Panadol", value="paracetamol", metadata={"type": "brand"})

for match in matcher.find("Panadol 500mg tablets"):
    print(match.text, match.value, match.start, match.end)

This prints Panadol paracetamol 0 7. The reported offsets always index the original Python string:

text = "Panadol 500mg tablets"
[match] = matcher.find(text)
assert text[match.start : match.end] == match.text

Guarantees

  • Case-insensitive matching uses locale-independent Unicode casefold(); optional NFC, NFD, NFKC, and NFKD normalization preserves source offsets.
  • Results are deterministic for the same configuration, terms, input, and Python Unicode data. They do not depend on term insertion order.
  • Explicit boundary and overlap policies make substring and collision behavior visible rather than accidental.
  • JSON save/load is validated and versioned. New POSIX files are created with mode 0o600, subject to the process umask.

Documentation

The documentation sources cover getting started, redacting known identifiers, tagging documents, Unicode and offsets, boundaries and overlap strategies, replacement, JSON persistence, FlashText migration, API reference, and performance limits.

Development

Run the library quality gate with uv sync --all-groups, then:

uv run ruff format --check .
uv run ruff check .
uv run ty check
uv run pytest
uv run sphinx-build -W --keep-going -b html docs docs/_build/html
uv build

See the contribution guide for development guidance and the release checklist for the maintainer workflow.

Metadata

Release files for lexneedle 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lexneedle 0.1.1
File Size Uploaded
lexneedle-0.1.1.tar.gz 15.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lexneedle 0.1.1
File Interpreter ABI Platform
lexneedle-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 35.1 kB

Release files / lexneedle-0.1.1.tar.gz

Download URL lexneedle-0.1.1.tar.gz
Size 15.4 kB
Tags Source
SHA-256 checksum
How to use checksums
237f726323d9f34228a9cf5d933eb476627c356347298aa53e698c214f1dc4ee
BLAKE2b-256 checksum
How to use checksums
196ab272c1b45e0be13232ddc5cefd5094147a38abb5e5bff272e2c83662e0a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / lexneedle-0.1.1-py3-none-any.whl

Download URL lexneedle-0.1.1-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a46eafb7f2573fa073ce1234b95765b32b265cd1b5da8d7d1461e1a1204ccba7
BLAKE2b-256 checksum
How to use checksums
db2d747137924b2f10de685332083b3dff84fddddc6b3a958b450bb1c0f5c3a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.17 {"installer":{"name":"uv","version":"0.12.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page