All Projects → AtomBoy → double-metaphone

AtomBoy / double-metaphone

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

Programming Languages

SQLPL
141 projects
python
139335 projects - #7 most used programming language

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].