Skip to content

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

Notifications You must be signed in to change notification settings

AtomBoy/double-metaphone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published