Skip to main content

No project description provided

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twat_text-2.7.9.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

twat_text-2.7.9-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file twat_text-2.7.9.tar.gz.

File metadata

  • Download URL: twat_text-2.7.9.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for twat_text-2.7.9.tar.gz
Algorithm Hash digest
SHA256 5ca2a66aa96f9cb2994e710ff22819e0d7131fcc7fe2e05fe62802d725f770f6
MD5 4f0459e28883dfcf0ba21492a1bbe3eb
BLAKE2b-256 cbed2153ac4013789a3054c3607e78fa1a9518eb5e18b33b82cbdcfc04f35b67

See more details on using hashes here.

File details

Details for the file twat_text-2.7.9-py3-none-any.whl.

File metadata

  • Download URL: twat_text-2.7.9-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for twat_text-2.7.9-py3-none-any.whl
Algorithm Hash digest
SHA256 3c498b1bba7abc418e040c88a56ba6b3f5332376ce5cd2e2719459c406986f8d
MD5 976e5285c2dd04ecc649b173db1bda40
BLAKE2b-256 3ad187e03af69d985b591d4cdfd7782ab0d6cc31d5c0f8ff22bceabe321e780e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page