PremoveITN.
The current package release is v0.3.0. It adds structured and contextual
views while retaining the frozen v0.2.0 model artifact. The model scores and
decoder output remain one inference result; temporal enrichment is deterministic
post-processing over that result.
Load the model
from_pretrained() downloads the pinned public model on first use and uses the
Hugging Face cache on later loads. Create one instance and reuse it. Model
initialization is expensive.
Parameters
model_idaccepts the public model ID or a local inference-artifact directory.revisionaccepts the pinned model commit or the verifiedv0.2.0model release tag.deviceacceptsauto,cpu,mps, orcuda.contextaccepts an optional defaultNormalizationContextfor later calls.
device="auto" selects CUDA when available, then Apple MPS, then CPU. CUDA is
an API option, but it is not a validated v0.3.0 platform claim.
Update an existing installation
Upgrade the package with the normal Python package manager:PremoveITN.from_pretrained() uses the current package
default and downloads the matching pinned model snapshot if it is not cached.
Hugging Face keeps snapshots by revision, so an older cached release is not
overwritten. There is no silent background package update.
Normalize a transcript
normalize() accepts one string and returns one string. It raises TypeError
for a non-string input. Empty and whitespace-only strings are returned
unchanged. If the text produces candidates, inputs longer than 512 DeBERTa
encoder tokens are rejected instead of being truncated. Text with no
candidates returns unchanged before tokenization.
Inspect structured normalization
Usenormalize_structured() when a downstream system needs the exact edits
selected by ITN:
NormalizationResult with:
text: readable normalized text.resolved_text: the machine-resolved text view.spans: selected edits as immutableNormalizedSpanvalues.
SpanKind, and an optional
resolved_value. These invariants hold for every selected span:
today, tomorrow, yesterday,
day after tomorrow, and day before yesterday. It keeps these expressions
in readable text and adds ISO calendar values to resolved_value and
resolved_text when reference_datetime is available. Without a reference
datetime, the expressions remain annotated but unresolved.
Selected named-month DATE spans without a year are also resolved with the
reference year. Explicit years always win. Invalid calendar dates remain
unresolved.
Weekday-qualified named dates are resolved only when the stated weekday agrees
with the resulting calendar date. A missing year uses the reference year; an
explicit year can resolve without context. Contradictory weekdays remain
unresolved.
Selected numeric DATE spans are resolved when their interpretation is
structurally unique. Ambiguous dates require DateOrder; otherwise they stay
unresolved. Numeric dates without a year require the reference year. The
resolver accepts slash, dash, dot, and space-separated fields without adding
format-specific context fields. When the year is omitted, DateOrder uses the
relative position of day and month; all six orders therefore collapse to
either day-month or month-day interpretation.
Several temporal expressions can be resolved in one result. The structured
view preserves every selected decoder span and every compatible contextual
DATE span, while resolved_text renders all resolved values in normalized-text
order. The three public views share one inference result; resolving temporal
metadata does not trigger a second model call.
Supply normalization context
Create an immutable context from explicit caller-owned facts:NormalizationContext() to replace an instance default with no
contextual facts for one call. Passing context=None uses the instance default.
DateOrder describes only the positional order of day, month, and year. It
supports all six permutations: DMY, DYM, MDY, MYD, YDM, and YMD.
It does not encode separators or surface formats. For example, 30/09/2026,
30-09-2026, and 30 09 2026 all use DateOrder.DMY. Named-month dates do
not need a date order when their fields are already unambiguous.
Return the resolved text view
normalize_resolved() is the string-only view of the same internal result:
normalize() when a supported contextual expression has a
deterministic value to render: