Skip to content

Commit ee2be5c

Browse files
committed
Metaphone should remove duplicate 'g'
Current PHP source code for metaphone removed duplicated 'g' characters. Don't know when it changed, but seems to be long ago.
1 parent fc1b73e commit ee2be5c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

functions/strings/metaphone.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ function metaphone(word, phones) {
55
// improved by: Rafał Kukawski (http://kukawski.pl)
66
// example 1: metaphone('Gnu');
77
// returns 1: 'N'
8+
// example 2: metaphone('bigger');
9+
// returns 2: 'BKR'
810

911
word = (word == null ? '' : word + '')
1012
.toUpperCase();
@@ -22,7 +24,7 @@ function metaphone(word, phones) {
2224
for (var i = 1; i < wordlength; i++) {
2325
char2 = word.charAt(i);
2426

25-
if (char2 !== char1 || char2 === 'C' || char2 === 'G') { // 'c' and 'g' are exceptions
27+
if (char2 !== char1 || char2 === 'C') { // 'c' is an exception
2628
rebuilt += char2;
2729
}
2830
char1 = char2;
@@ -256,4 +258,4 @@ function metaphone(word, phones) {
256258
return metaword.substr(0, phones);
257259
}
258260
return metaword;
259-
}
261+
}

0 commit comments

Comments
 (0)