Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

phonematcher

phonematcher measures how far apart two IPA sounds are, and finds terms that sound like a query. It works on IPA only. To get IPA from text, use a grapheme-to-IPA library such as orthography2ipa.

Every distance comes from distinctive features. The feature table starts from PanPhon (Mortensen et al. 2016), takes the vowels from the IPA chart, and lists every other change with its source. docs/features.md explains the table.

Install

uv pip install phonematcher

phonematcher has no runtime dependencies.

Distance between sounds

from phonematcher import feature_distance, ipa_distance, segments, substitution_cost

feature_distance("ʁ", "χ")       # 0.013: uvular fricatives that differ only in voice
feature_distance("ʁ", "k")       # 0.118: a different manner, place and voice
substitution_cost("ʁ", "χ")      # 0.115: the square root of the feature distance
segments("ˈt͡ʃɐ̃w̃")              # ['t͡ʃ', 'ɐ̃', 'w̃']
ipa_distance("ˈpojʃ", "ˈpojs")   # 0.199: one near substitution

feature_distance compares two segments, from 0 to 1. substitution_cost is the one cost of replacing a segment by another. It is the square root of the feature distance. ipa_distance compares two IPA strings: an edit distance where a substitution costs substitution_cost and an insertion or deletion costs 0.5. A substitution costs at most 1, so it never costs more than a deletion plus an insertion. The search groups sounds with the same cost. The costs are the ones that the pre-registered test in benchmarks/prereg-2.md selected.

Search by sound

from orthography2ipa import transcribe
from phonematcher import PhoneticFuzzySearch

search = PhoneticFuzzySearch()
for word in ["pois", "retirada", "carro", "caro", "casa", "dia"]:
    search.add_term(transcribe(word, "pt-PT"), word)

query = transcribe("carro", "pt-BR-x-rj")   # 'ˈkaχu'
best = search.search(query)[0]
best.id, best.term, round(best.score, 3)   # ('carro', ('ˈkaʁu',), 0.115)

A term may have several readings: search.add_term(["ˈpojʃ", "ˈpojs"], "pois").

Documentation

Licence

MIT. The feature table derives from PanPhon (MIT) and from Hayes (2009) through the CSV conversion by Kyle Gorman (Apache-2.0).

To cite phonematcher, use CITATION.cff.

Metadata

Release files for phonematcher 2.0.0a1

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

Source distribution (sdist)

Source distribution for phonematcher 2.0.0a1
File Size Uploaded Provenance Actions
phonematcher-2.0.0a1.tar.gz 116.7 kB Without provenance Details for phonematcher-2.0.0a1.tar.gz

Built distribution (wheel)

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

Total release size: 180.5 kB

Release files / phonematcher-2.0.0a1.tar.gz

Download URL phonematcher-2.0.0a1.tar.gz
Size 116.7 kB
Tags Source
SHA-256 checksum
How to use checksums
136c9e2cd3e7cf2dcb9f9d761eb37e1c9729f1873c2634daad84414a07111757
BLAKE2b-256 checksum
How to use checksums
34b5493840c89ed6fc57b39bedeb13e01e1f154693b3eb347f37ec56c9aeb32b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / phonematcher-2.0.0a1-py3-none-any.whl

Download URL phonematcher-2.0.0a1-py3-none-any.whl
Size 63.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32732fbe50a944e232c0cba33a5cb712dfb9827b6509c7600956760a274b8671
BLAKE2b-256 checksum
How to use checksums
b00d26a565ff38d840c6f22530d9051c40c3e05ab88f51736420a6089423f2b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for phonematcher 2.0.0a1

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.

Release history Release notifications | RSS feed

This release
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