Metaphone

0.6 · maintenance · verified Thu Apr 16

Metaphone is a Python library that provides implementations of the Metaphone and Double Metaphone phonetic algorithms. These algorithms are designed to index words by their English pronunciation, offering an improvement over Soundex for matching similar-sounding words and names, even with variations in spelling. The Double Metaphone algorithm further refines this by accounting for spelling peculiarities from various languages and can return both a primary and a secondary phonetic code. The current version is 0.6, and the project has a very slow release cadence, with the last PyPI update in 2016 and the latest GitHub release in 2020.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use both the `doublemetaphone` and `metaphone` functions to generate phonetic codes for words. Double Metaphone returns a tuple of two codes (primary and secondary), while Metaphone returns a single code.

from metaphone import doublemetaphone

word = "architect"
primary_code, secondary_code = doublemetaphone(word)
print(f"Original word: {word}")
print(f"Double Metaphone codes: Primary='{primary_code}', Secondary='{secondary_code}'")

word_two = "Schmidt"
primary_code_two, secondary_code_two = doublemetaphone(word_two)
print(f"Original word: {word_two}")
print(f"Double Metaphone codes: Primary='{primary_code_two}', Secondary='{secondary_code_two}'")

from metaphone import metaphone
word_three = "example"
metaphone_code = metaphone(word_three)
print(f"Original word: {word_three}")
print(f"Metaphone code: '{metaphone_code}'")

view raw JSON →