Skip to main content

twat-text

twat-text is the user-facing text utility package in the twat ecosystem.

It keeps deterministic text algorithms local and delegates LLM-powered operations to twat_llm through a narrow adapter. Generated images, video, audio, and speech belong in twat_genai and media domain packages, not here.

Install

pip install twat-text

Deterministic API

from twat_text import clean_text, chunk_text, extract_emails, convert_text, estimate_tokens

text = clean_text(" “Hello”\tworld ")
chunks = chunk_text(long_document, max_chars=2000, overlap=100)
emails = extract_emails("Ada <ada@example.com>")
plain = convert_text("<p>Hello &amp; welcome</p>", source="html", target="plain")
tokens = estimate_tokens(plain)

Available deterministic helpers include:

  • normalize_text and clean_text
  • chunk_text and context_window_chunks
  • extract_urls, extract_emails, and extract_numbers
  • markdown_to_plain, html_to_plain, plain_to_html, and convert_text
  • estimate_tokens

LLM-backed API

from twat_text import summarize, rewrite, extract_structured, classify

summary = summarize(long_text)
rewrite = rewrite(draft, instruction="Make this friendlier")
data = extract_structured(note, schema_hint="Return JSON with date and total")
label = classify(message, labels=["support", "sales", "spam"])

These functions import twat_llm only when called, so deterministic utilities stay dependency-light and testable.

CLI

twat-text clean "  Hello   world  "
twat-text chunk "long text..." --max-chars 500 --overlap 50
twat-text convert "<p>Hello</p>" --source html --target plain
twat-text summarize "long text..."
twat-text rewrite "draft text" --instruction "Make it concise"

Through the host plugin dispatcher, the same package is available as twat text ... once installed.

Proposition segmentation (APS)

twat_text.aps rewrites long Markdown corpora into atomic, self-contained propositions through free LLM routes, with durable SQLite state, fingerprinted runs and no silent retries.

pip install "twat-text[aps]"
twat-aps-books prepare --root docs/ --work work/ --output out/
twat-aps-books run --root docs/ --work work/ --output out/ --models freellm:unorouter:glm-5.3-flash:free

See docs/aps.md for the quality audit and semantic hierarchy commands.

Development

hatch run test
hatch run lint
hatch run type-check

The compatibility Config and process_data API remains available, but process_data now returns cleaned text, chunks, simple extracted values, and an estimated token count instead of an empty placeholder.

Metadata

Release files for twat-text 2.8.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 twat-text 2.8.1
File Size Uploaded Provenance Actions
twat_text-2.8.1.tar.gz 1.3 MB With provenance Details for twat_text-2.8.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for twat-text 2.8.1
File Interpreter ABI Platform Actions
twat_text-2.8.1-py3-none-any.whl Python 3 none any Details for twat_text-2.8.1-py3-none-any.whl

Total release size: 1.3 MB

Release files / twat_text-2.8.1.tar.gz

Download URL twat_text-2.8.1.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
5af9d53348802d5a91f809ca42826b9a2ff2eeb543df632e7709b67d3ae9ffc6
BLAKE2b-256 checksum
How to use checksums
fb456a29adb064b105854d171ce602ecdb4c8bb1eba94598818239e1ecb3f87f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Release files / twat_text-2.8.1-py3-none-any.whl

Download URL twat_text-2.8.1-py3-none-any.whl
Size 69.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ec9b4c92abd6a4d2455009387ab7bec45530c86d035906e84218c324c1f56d1d
BLAKE2b-256 checksum
How to use checksums
bfa88fe0af450900e78a5dde9f41bd1f196286f6223507da181dda92ff875fda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

Security for twat-text 2.8.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for twat_text-2.8.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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