mailtext
Local Rust library and CLI for inspecting mail text. It returns sections for the current body, quoted thread, signature and legal footer. It also returns sentence and paragraph language evidence and candidates for dates and phone numbers.
cargo build --release -p mailtext
target/release/mailtext plain --lang en-GB < synthetic.txt
target/release/mailtext html < synthetic.html
target/release/mailtext eml < synthetic.eml
The CLI reads one message from standard input and writes one JSON result to standard output. That result contains message data. Error messages use fixed text. The library returns results to the caller. Processing makes no network requests and writes no files.
The Rust entry points are normalize(text, lang),
normalize_parts(plain, html, lang) and normalize_message(bytes, lang).
The optional hint guides date ordering and national phone normalization.
MIME transfer and charset choices are recorded in mime_rules.
Language tags come from the text. Mail parsing selects the first inline body
branch and prefers plain text within multipart alternatives, including empty
plain text. A related multipart contributes its designated root. Attachments
and embedded messages are skipped. HTML rendering decodes entities, folds
nonbreaking spaces to spaces, renders table cells with tabs and represents
blockquotes with quote prefixes. It ignores script, style and explicitly
hidden elements. CSS and remote resources are outside the renderer.
source_text is the decoded plain body or rendered HTML, with LF line
endings. text is the result of encoded-word and mojibake repair.
source_span addresses the first string and span addresses the second.
Both use half-open UTF-8 byte coordinates. Candidates carry the original
source slice, normalized value and reason. Edits identify both ranges and
their repair rule. HTML offsets address the rendering. Each section covers
a contiguous span and records the triggering rule and marker when available.
Reply headers can span up to three lines. An explicit thread opener ordinarily
owns the tail. A clearly marked footer can follow an entirely prefixed tail.
Language identification uses langseg's English/French table and tokenization
with additional German mail words, Ukrainian/Russian Cyrillic cues and Korean
Hangul evidence. Unsupported or weak evidence is marked und at the token
level. languages lists the supported codes seen in a unit. mixed requires
at least two supported codes. The reused English/French reader observes
langseg's MOVA_VERNACULAR setting.
Date rules recognize full calendar dates and return both valid readings of an ambiguous numeric date when a hint leaves the order unresolved. Phone rules normalize explicit international prefixes and selected national formats. Without a supported region hint, recognizable national numbers retain local digits. These are text candidates. Allocation and deliverability are outside the phone rules. Mojibake repair is conservative and can leave ambiguous encodings untouched. Unmarked quotation, signature and footer boundaries remain heuristic.
cargo test -p mailtext --offline
cargo test -p mailtext --offline planted_precision_recall -- --nocapture
The tests use synthetic letters. The split measure evaluates the four part labels on nonblank visible lines and includes an all-body negative control.
This page in Markdown https://md.mova.elamur.ai/free/en/docs/tools/mailtext/