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 phonetic_distance, ipa_distance, segments
phonetic_distance("ʁ", "χ") # 0.013: uvular fricatives that differ only in voice
phonetic_distance("ʁ", "k") # 0.118: a different manner and place
segments("ˈt͡ʃɐ̃w̃") # ['t͡ʃ', 'ɐ̃', 'w̃']
ipa_distance("ˈpojʃ", "ˈpojs") # 0.039: one near substitution
phonetic_distance compares two segments, from 0 to 1. ipa_distance compares two IPA strings: an edit distance where a substitution costs the feature distance and an insertion or deletion costs 1.
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.013)
A term may have several readings: search.add_term(["ˈpojʃ", "ˈpojs"], "pois").
Documentation
- docs/quickstart.md: first steps.
- docs/features.md: the feature table, its sources and the distance.
- docs/api.md: every public name.
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 0.18.0a1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phonematcher-0.18.0a1.tar.gz | 107.1 kB | Without provenance | Details for phonematcher-0.18.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phonematcher-0.18.0a1-py3-none-any.whl | Python 3 | none | any | Details for phonematcher-0.18.0a1-py3-none-any.whl |
Total release size: 169.6 kB
Release files / phonematcher-0.18.0a1.tar.gz
| Download URL | phonematcher-0.18.0a1.tar.gz |
|---|---|
| Size | 107.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
58f3c775c80dd3dd5519b2a9d8c11a9495f67f0761d5d64265f120da2a6dbd77
|
|
BLAKE2b-256 checksum How to use checksums |
4dc2e93d482525dd4f6abef7e40086c13aaa25dff7054888d8fd74b998be9287
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Release files / phonematcher-0.18.0a1-py3-none-any.whl
| Download URL | phonematcher-0.18.0a1-py3-none-any.whl |
|---|---|
| Size | 62.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6441ecb9cbcc4bc817a6aefc07a17ff7c435b673138c53eeea9047397bbf6710
|
|
BLAKE2b-256 checksum How to use checksums |
03b0a0a741d84d1f4f4642b15709b8f1c59ab7be22fdc7a2032a5e3367990b2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Security for phonematcher 0.18.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.