type: blog title: Fuzzy search using the Double Metaphone algorithm description: Using the Double Metaphone algorithm to find words that sound alike. layout: default date: 2019-07-02 author: Brian Wilkins image: assets/img/chris-barbalis-1217112-unsplash.jpg authorLink: relcanonical:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
// Match vowels (including `Y`). | |
var vowels = /[AEIOUY]/ | |
// Match few Slavo-Germanic values. | |
var slavoGermanic = /W|K|CZ|WITZ/ | |
// Match few Germanic values. | |
var germanic = /^(VAN |VON |SCH)/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cajkovskij | |
Chaikovsky | |
Chaĭkovski | |
Chaĭkovskiĭ | |
Ciaikovski | |
Ciaikovskij | |
Ciaikovskji | |
Ciaikovsky | |
Csajkovszkij | |
Czajkowski |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_id": "_design/doubleMetaphone", | |
"views": { | |
"doubleMetaphone": { | |
"map": "'use strict'\n\n// Match vowels (including `Y`).\nvar vowels = /[AEIOUY]/\n\n// Match few Slavo-Germanic values.\nvar slavoGermanic = /W|K|CZ|WITZ/\n\n// Match few Germanic values.\nvar germanic = /^(VAN |VON |SCH)/\n\n// Match initial values of which the first character should be skipped.\nvar initialExceptions = /^(GN|KN|PN|WR|PS)/\n\n// Match initial Greek-like values of which the `CH` sounds like `K`.\nvar initialGreekCh = /^CH(IA|EM|OR([^E])|YM|ARAC|ARIS)/\n\n// Match Greek-like values of which the `CH` sounds like `K`.\nvar greekCh = /ORCHES|ARCHIT|ORCHID/\n\n// Match values which when following `CH`, transform `CH` to sound like `K`.\nvar chForKh = /[ BFHLMNRVW]/\n\n// Match values which when preceding a vowel and `UGH`, sound like `F`.\nvar gForF = /[CGLRT]/\n\n// Match initial values which sound like either `K` or `J`.\nvar initialGForKj = /Y[\\s\\S]|E[BILPRSY]|I[BELN]/\n\n// Match initial values which sound lik |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
module.exports = doubleMetaphone | |
// Match vowels (including `Y`). | |
var vowels = /[AEIOUY]/ | |
// Match few Slavo-Germanic values. | |
var slavoGermanic = /W|K|CZ|WITZ/ |