Registry / data / phonetics

phonetics

JSON →
library1.0.5pypypi✓ verified 84d ago

The `phonetics` library is a Python module designed to compute phonetic keys of strings for indexing or fuzzy matching. It implements several classic phonetic algorithms including Soundex, NYSISS, Metaphone, and Double Metaphone. The library's last release was in March 2018, and it is marked with a '3 - Alpha' development status, primarily supporting Python 2.x and early Python 3.x versions up to 3.5.

pip install phonetics
INSTALL
IMPORT
SIG · PHONETICS
P
phonetics
datapythonv1.0.5
Install
2.4s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.3MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.4s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

phonetics
import phonetics
from phonetics import Soundex
The library typically exposes functions directly under the 'phonetics' module rather than as separate classes or methods for each algorithm. You call functions like `phonetics.soundex()` or `phonetics.metaphone()` directly.

Demonstrates how to import the `phonetics` module and use its core phonetic encoding functions like `soundex`, `metaphone`, and `dmetaphone` to generate phonetic keys for strings.

import phonetics # Soundex algorithm print(f"Soundex for 'Python': {phonetics.soundex('Python')}") print(f"Soundex for 'Pythn': {phonetics.soundex('Pythn')}") # Metaphone algorithm print(f"Metaphone for 'example': {phonetics.metaphone('example')}") print(f"Metaphone for 'xylophone': {phonetics.metaphone('xylophone')}") # Double Metaphone algorithm # Returns a tuple of primary and secondary keys primary_key, secondary_key = phonetics.dmetaphone('Danger') print(f"Double Metaphone for 'Danger': ({primary_key}, {secondary_key})") primary_key, secondary_key = phonetics.dmetaphone('Denger') print(f"Double Metaphone for 'Denger': ({primary_key}, {secondary_key})")
Debug
Known issues
breakingThe `phonetics` library explicitly supports Python versions up to 3.5. Running it on newer Python versions (3.6+) may lead to compatibility issues, unexpected errors, or incorrect behavior due to changes in Python's standard library or language syntax over time.
fix
Consider using alternative, actively maintained phonetic libraries like `pyphonetics`, `cologne-phonetics`, or `fuzzywuzzy` for modern Python environments. If you must use `phonetics`, run it in a Python 3.5 or earlier environment.
affects: Python 3.6+
gotchaThe library is in 'Alpha' development status, indicating it may not be production-ready and could have undocumented quirks or bugs. Its last release was in 2018, suggesting a lack of active maintenance and potential security vulnerabilities.
fix
Evaluate alternatives for new projects. If using it, thoroughly test its behavior in your specific environment and use case. Be aware that community support or bug fixes are unlikely.
affects: All versions (1.x.x)
gotchaThe `phonetics` library focuses on traditional phonetic algorithms (Soundex, Metaphone, NYSISS) for string key generation, which are primarily designed for English or Germanic languages. It does not provide advanced linguistic analysis, IPA (International Phonetic Alphabet) transcription, or support for a wide range of global languages.
fix
For advanced phonetic analysis, IPA support, or multi-language phonetics, consider libraries like `epitran`, `panphon`, `gruut-ipa`, or `phonecodes`. This library is best suited for simple, traditional phonetic encoding tasks.
affects: All versions (1.x.x)
Errors
Common errors & fixes
TypeError: object of type 'NoneType' has no len()
This error often occurs when one of the phonetic functions (e.g., `dmetaphone`) is called with an input that results in `None` being returned for one of its internal steps, and subsequent operations try to apply a length check to this `None` value. This can happen with unusual or empty string inputs, especially with older Python versions.
fix
Ensure that the input strings to phonetic functions are valid (non-empty, appropriate characters). Wrap calls in a `try-except` block to gracefully handle `None` returns or `TypeError`s. Example: `result = phonetics.dmetaphone(my_string); if result: print(result)`.
AttributeError: module 'phonetics' has no attribute 'some_new_function'
Users might expect functionalities or algorithms present in other `phonetics`-related libraries (e.g., `pyphonetics`, `cologne-phonetics`) or newer versions of general phonetic tools to be available in this specific `phonetics` library.
fix
Verify the exact functions and classes exposed by *this* `phonetics` library by consulting its PyPI page or source code (Soundex, NYSISS, Metaphone, Double Metaphone are confirmed). If you need other algorithms, install and use a different library.
Upgrade
Version history
1.0.5latest on PyPI · released Mar 23, 2018
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
phonetics — pip install phonetics · libregistry