Registry / serialization / doublemetaphone

doublemetaphone

JSON →
library1.2pypypi✓ verified 91d ago

The `doublemetaphone` library provides a Python wrapper for the C++ implementation of the Double Metaphone phonetic algorithm. This algorithm generates approximate phonetic representations (codes) for words, useful for matching names or words with similar pronunciations despite different spellings. The current version is 1.2. Releases appear to be infrequent, with significant gaps between updates.

pip install doublemetaphone
INSTALL
IMPORT
SIG · DOUBLEMETAPHONE
D
doublemetaphone
serializationpythonv1.2
Install
1.6s avg
Import
—
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v1.2 · 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.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 21.9MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.000s · 19MB
18MB installed
● package 18MB
Code
Verified usage

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

doublemetaphone
✓ from doublemetaphone import doublemetaphone
✗ import doublemetaphone; doublemetaphone.doublemetaphone.doublemetaphone('word')
The primary function is directly exposed from the top-level package, not nested further.

Generate Double Metaphone codes for a word and compare them. The function returns a tuple of (primary_code, secondary_code).

from doublemetaphone import doublemetaphone word1 = "Smith" word2 = "Schmidt" primary1, secondary1 = doublemetaphone(word1) primary2, secondary2 = doublemetaphone(word2) print(f"'{word1}': Primary='{primary1}', Secondary='{secondary1}'") print(f"'{word2}': Primary='{primary2}', Secondary='{secondary2}'") # Double Metaphone often returns two codes to account for phonetic ambiguities. # For example, 'Smith' and 'Schmidt' share a secondary code. if primary1 == primary2 or secondary1 == secondary2 or primary1 == secondary2 or primary2 == secondary1: print(f"'{word1}' and '{word2}' are phonetically similar.")
Debug
Known issues
gotchaThe `doublemetaphone` function returns a tuple of two strings (primary and secondary codes), not a single string. Ensure your code handles both return values, even if one is an empty string.
fix
Always unpack the return value into two variables: `primary, secondary = doublemetaphone('word')`.
affects: All versions
breakingOlder versions (primarily Python 2) might have raised `TypeError` if non-unicode strings were passed. Python 3 strings are Unicode by default, but be mindful of encoding if dealing with byte strings or legacy data.
fix
Ensure all input strings are Python 3 `str` objects (Unicode). Explicitly decode byte strings if necessary (e.g., `my_bytes.decode('utf-8')`).
affects: <1.1 (Python 2), potential edge cases in 1.x with bytes
gotchaThere are multiple Python packages implementing or wrapping Metaphone/Double Metaphone algorithms (e.g., `metaphone`, `phonetics`, `doublemetaphone`). Ensure you install and import the correct package for the C++ wrapper implementation (`doublemetaphone`).
fix
Verify the `pip install` command and `import` statement match the `doublemetaphone` package specifically. Check the PyPI project description to confirm it's the C++ wrapper.
affects: All versions
gotchaInstallation might require a C++ compiler if a pre-built wheel is not available for your specific Python version and operating system. This is common for Python wrappers around C/C++ libraries.
fix
If `pip install` fails with compilation errors, install a C++ compiler (e.g., build-essential on Linux, Xcode Command Line Tools on macOS, Visual C++ Build Tools on Windows) or consider using a pre-packaged environment (e.g., Docker).
affects: All versions, on environments without compatible wheels
Errors
Common errors & fixes
ERROR: Failed building wheel for doublemetaphone
This error indicates that `pip` was unable to compile the C++ extension required by the `doublemetaphone` library, often due to a missing C++ compiler or development tools on your system.
fix
On Windows, install 'Build Tools for Visual Studio' (specifically, the C++ build tools). On Linux, install `build-essential` (e.g., `sudo apt-get install build-essential`). For Python versions where setuptools might have issues, ensure setuptools is updated: `pip install --upgrade setuptools pip`.
ImportError: DLL load failed while importing doublemetaphone: The specified module could not be found.
This specific `ImportError`, commonly seen on Windows, means that a dynamically linked library (DLL) that `doublemetaphone` depends on could not be located by the Python interpreter, often related to the Visual C++ Redistributable.
fix
Ensure that the Microsoft Visual C++ Redistributable for your Python version (e.g., 2015-2022) is installed. Also, verify that the `doublemetaphone` package was installed correctly in the active Python environment.
ModuleNotFoundError: No module named 'doublemetaphone'
This error means Python cannot find the `doublemetaphone` package, usually because it was not installed, was installed in a different Python environment, or the installation failed without a clear error message.
fix
Ensure you have installed the package using `pip install doublemetaphone` in the correct Python environment. If you have multiple Python installations, activate the intended environment before installing or specify the Python executable (e.g., `python -m pip install doublemetaphone`).
Upgrade
Version history
1.2latest on PyPI · released May 11, 2025
Audit
Dependencies
C++ compileroptionalThis is a Python wrapper for a C++ library. While pre-built wheels are often available, a C++ compiler (like GCC or MSVC) is required if installing from source or for platforms without pre-built wheels.
Agent activity
8 hits · last 30 days
node
8
Resources
doublemetaphone — pip install doublemetaphone · libregistry