Python and MySQL implementations of the double metaphone algorithm which is useful for matching different spellings of names.
SQLPL Python
Latest commit 6309de5 Jan 24, 2016 @AtomBoy Minor edits to docs.
Permalink
Failed to load latest commit information.
README.md Minor edits to docs. Jan 25, 2016
metaphone.py Update README and URLs. Jan 23, 2016
metaphone.sql Update README and URLs. Jan 23, 2016

README.md

double-metaphone

Python and MySQL implementations of the double metaphone algorithm which is useful for matching different spellings of names.

See Wikipedia for a good explanation of the algorithm.

There is a more recent version of Metaphone called Metaphone 3. It is a commercial product available at http://www.amorphics.com/ (which I am not affiliated with).

MySQL Usage

To create the command from your command line:

mysql yourDataBaseName -u root -p < metaphone.sql

Then, from a mysql command line you can test it with:

mysql> USE yourDataBaseName;
Database changed
mysql> SELECT dm('collins');
+---------------+
| dm('collins') |
+---------------+
| KLNS          |
+---------------+
1 row in set (0.01 sec)

Normally you'll want to pre-compute the metaphone values for names in your database and put them into an indexed column:

INSERT INTO people (lastName, lastNameDM) VALUES (${lastName}, dm(${lastName}))

Then query for matches against the latNameDM column computing only the name to find:

SELECT * FROM people WHERE lastNameDM = dm(${inputLastName})

Checking for equality is the simplest, but dm() can return two metaphones- a primary and a secondary separated by a semicolon. You can check that any metaphone matches any other metaphone for looser matches.