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.

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.

Release files for twat-text 2.7.10

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.7.10
File Size Uploaded
twat_text-2.7.10.tar.gz 18.9 kB Details

Built distribution (wheel)

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

Total release size: 28.3 kB

Release files / twat_text-2.7.10.tar.gz

Download URL twat_text-2.7.10.tar.gz
Size 18.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0d4a5bd7545a76c76827a12b3c0abc9536b11204a0d7d0ed1d2fbd9bf571a2c8
BLAKE2b-256 checksum
How to use checksums
1c4b6252240e54ba4aeecaa0baf6a5fff6fb062c86e53fcf44566602cbbeb9ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

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

Download URL twat_text-2.7.10-py3-none-any.whl
Size 9.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
75ca06c2057149be9a73b193a20c429711612fe6e755816fd37a54fad8e914f2
BLAKE2b-256 checksum
How to use checksums
4b53a87d6bc0f5a980a30dd1dc20a232f85c04a8f1dd3ceebdc6502a1414d2f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

2.7.10 This release

2 release files

2.7.9

2 release files

2.7.8

2 release files

2.7.7

2 release files

2.7.5

2 release files

2.6.2

2 release files

2.6.1

2 release files

2.6.0

2 release files

2.5.3

2 release files

2.5.2

2 release files

2.5.1

2 release files

2.1.3

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.16

2 release files

1.7.15

2 release files

1.7.14

2 release files

0.0.1

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