Skip to content

API Reference parrot_formdesigner.audio.normalize.numbers

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_formdesigner.audio.normalize.numbers

View source

Spoken/written number parsing shared by every typed post-processor (FEAT-653).

Attribute APPROXIMATE_FRACTION

Alias NormalizeContext

Re-exported from parrot_formdesigner.audio.normalize.base.NormalizeContext.

Alias NormalizeResult

Re-exported from parrot_formdesigner.audio.normalize.base.NormalizeResult.

Alias SpokenLexicon

Re-exported from parrot_formdesigner.audio.narration.lexicon.SpokenLexicon.

Attribute UNHANDLED_FRACTION

Attribute logger

Function normalize_number

Exactly one number → accepted int/float; 0 or >1 numbers → rejected (no_parse / multiple_values).

normalize_number(text: str, ctx: NormalizeContext, *, integer: bool) -> NormalizeResult

Parameter Type Default Description
text str
ctx NormalizeContext
integer bool

Returns: NormalizeResult

Function parse_numbers

Every number in the token stream, in order (words and written digits).

colloquial additionally reads a bare point five as 0.5 and two and a half / dos y medio as 2.5, one and three quarters as 1.75. When notes is given it collects approximate_fraction for a fraction that is not exact (thirds…) and one fraction_consumed per fraction word that was read.

parse_numbers(tokens: list[str], spoken: SpokenLexicon, *, colloquial: bool = False, notes: list[str] | None = None) -> list[int | float]

Parameter Type Default Description
tokens list[str]
spoken SpokenLexicon
colloquial bool False
notes list[str] | None None

Returns: list[int | float]

Function tokenize

Casefold + accent fold, keep digits and @ + . / : , -, split on whitespace.

Trailing sentence punctuation (.,:;) is stripped from every token, so com. becomes com and 25, becomes 25 while 3.5 and 0,4,12 are kept intact.

tokenize(text: str) -> list[str]

Parameter Type Default Description
text str

Returns: list[str]

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally