Skip to main content

pronresolve

pronresolve discovers same-spelling, same-part-of-speech pronunciation ambiguity from dictionary data and chooses a reading from sentence context only when evidence is strong enough. It is an alpha, data-driven MVP: there is no word-specific heteronym table and no runtime dependency on Lexhint, G2Lex, or Lexphon.

Install

python -m pip install pronresolve

For development and documentation:

python -m pip install -e ".[dev,docs]"
python -m pytest
python -m sphinx -W --keep-going -b html docs docs/_build/html

Versions are derived from Git tags with setuptools-scm. Source archives without Git metadata use the configured development fallback version. The current CI matrix verifies Python 3.10–3.13; Python 3.14 has not yet been added to the supported/tested release matrix.

Concept and discovery

The build pipeline streams dictionary-entry mappings or objects into discover_ambiguities(). The package groups by normalized spelling and POS, normalizes pronunciations, and generates stable reading IDs.

from pronresolve import discover_ambiguities, save_index

result = discover_ambiguities(lexicon.iter_entries(), language="en", locale="en-US")
save_index(result.index, "en-us.pronresolve.json")
print(result.report.as_dict())

A key with only one IPA is not ambiguous. Multiple IPA values on one source entry are treated as unlinked ambiguity and omitted rather than guessed. Entries with missing or empty POS are excluded from automatic resolution and counted in entries_without_pos in the discovery report. Missing pronunciation is also counted separately.

Runtime resolution

Load the generated file and provide original sentence text and target character offsets. POS and lemma are useful when the caller has them:

from pronresolve import Resolver

resolver = Resolver.from_path("en-us.pronresolve.json")
decision = resolver.resolve(
    text="The archer picked up the bow and an arrow.",
    start=25,
    end=28,
    pos="NOUN",
    lemma="bow",
)
if decision is not None:
    selector = decision.selector
    ipa = decision.ipa

A None result means the existing default pronunciation path should remain in use. The resolver is deterministic and explainable, not a claim of linguistic certainty.

CLI

pronresolve --help
pronresolve build --input-jsonl entries.jsonl --output index.json --language en --locale en-US
pronresolve inspect index.json [--word WORD]
pronresolve validate index.json

build reads one JSON object per non-empty JSONL line and writes a compact v2 index plus <output>.report.json. inspect prints summary counts; add --word WORD to view each reading's IPA, sense IDs, and weighted cues. validate accepts v1 and v2. Invalid input or an invalid index returns exit code 2 and writes a concise pronresolve: error: ... message to stderr.

What pronresolve stores

The resolver index is a compact decision artifact, not a copy of dictionary records. Schema v2 groups candidates by normalized word and POS. Each runtime reading profile contains a reading ID, scalar IPA, sense IDs, and normalized cue tokens grouped by weight. Raw gloss, synonym, topic, tag, antonym, example, and etymology prose is not stored in runtime profiles.

Policy B runtime scoring

Evidence field Weight
Synonyms 3.5
Glosses 3.0
Topics 2.5
Tags 1.0
Antonyms 0.75

Examples are excluded from runtime scoring and serialized cues. They are disproportionately large, can contain incidental words unrelated to sense identity, and are unnecessary for compact lexical matching; they may still be retained privately as build/audit evidence. Repeated cue tokens keep their maximum field weight rather than adding weights. Antonyms retain positive-association behavior for parity; signed or removed antonym evidence is deferred.

Schema compatibility

New indexes are written as compact, deterministic schema v2 JSON. The loader also accepts schema v1, compiles its synonyms, glosses, topics, tags, and antonyms into Policy B cues, and deliberately ignores examples and etymology numbers for runtime resolution. Therefore v1 scores are not guaranteed to match the previous resolver when examples contributed evidence.

The runtime ReadingProfile API intentionally changed: IPA is scalar and lexical evidence is exposed as compiled Cue values instead of raw prose fields. Resolution.ipa is also scalar. Callers should use the returned sense_ids, evidence_terms, and reading ID for runtime explanation and selection.

Schema-v2 JSON uses schema_version, language, locale, and an entries object grouped as word -> POS -> candidates; each candidate stores id, scalar ipa, optional sense_ids, and cues grouped by weight. Unsupported versions and malformed structures are rejected. Dataset/version identity belongs to the containing lexicon package or artifact metadata, not the index JSON; publish the index beside its matching pronunciation lexicon.

Integration boundary

The producer supplies dictionary entries and locale-filtered source data. Consumers load the generated index, pass token spans/context to the resolver, and apply the returned READING:<reading_id> selector through their existing selector-aware lookup. Locale is stored as metadata only; runtime locale filtering is not performed here.

Limitations

  • No morphological lemmatization: matching uses exact normalized context tokens.
  • No runtime locale filtering; prepare correctly filtered locale-specific indexes upstream.
  • No automatic sense-to-IPA linking when one source entry has multiple IPA values.
  • Entries without POS are skipped by discovery and counted in its report.
  • Resolver thresholds are heuristic defaults; conservative abstention is expected when context is weak or scores are close.
  • Antonyms currently count as positive related-term evidence, not negative evidence.

Documentation

The full user guide and public API reference are in the Sphinx documentation. Build with python -m pip install -e ".[docs]" followed by python -m sphinx -W --keep-going -b html docs docs/_build/html.

License

Apache License, Version 2.0. See LICENSE.

Metadata

Release files for pronresolve 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pronresolve 0.1.1
File Size Uploaded Provenance Actions
pronresolve-0.1.1.tar.gz 41.2 kB Without provenance Details for pronresolve-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pronresolve 0.1.1
File Interpreter ABI Platform Actions
pronresolve-0.1.1-py3-none-any.whl Python 3 none any Details for pronresolve-0.1.1-py3-none-any.whl

Total release size: 65.0 kB

Release files / pronresolve-0.1.1.tar.gz

Download URL pronresolve-0.1.1.tar.gz
Size 41.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a8911598465b59fa781337ae151e3d4714cdb483fd3238d49b1b5c5fe6bce688
BLAKE2b-256 checksum
How to use checksums
97801a9927974704564ee2ac4c7832f2af648402e541df4b3ddacae3c6e6c5b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / pronresolve-0.1.1-py3-none-any.whl

Download URL pronresolve-0.1.1-py3-none-any.whl
Size 23.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6208c75485a17e6b58daa22d28d4132ba6b01c862126bb4ec895ef0e38e91d5b
BLAKE2b-256 checksum
How to use checksums
54aa329bd6a66ad2b21aebd4feba79cd17a9fecb50e6e76e73b5b8c0699f7cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for pronresolve 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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