Skip to content

Commit 81ffb59

Browse files
committed
Metaphone: fixed handling of 'T' chars
In PHP 5.3 the handling of 'T' changed to not include it in result when followed by 'CH'.
1 parent f58e030 commit 81ffb59

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

functions/strings/metaphone.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function metaphone(word, phones) {
8989
}
9090
} else if (nc === 'H') {
9191
metaword += 'X';
92-
x++;
92+
x += 1;
9393
} else {
9494
metaword += 'K';
9595
}
@@ -202,16 +202,13 @@ function metaphone(word, phones) {
202202
}
203203
break;
204204
case 'T':
205-
if (x + 1 <= wordlength) {
206-
if (nc === 'H') {
207-
metaword += '0';
208-
} else if (x + 2 <= wordlength && nc === 'I' && 'AO'.indexOf(nnc) !== -1) {
209-
metaword += 'X';
210-
} else {
211-
metaword += 'T';
212-
}
213-
} else {
205+
if (nc === 'I' && (nnc == 'O' || nnc === 'A')) {
206+
metaword += 'X';
207+
} else if (nc === 'H') {
208+
metaword += '0';
209+
} else if (word.substr(x + 1, 2) !== 'CH') {
214210
metaword += 'T';
211+
x += 1;
215212
}
216213
break;
217214
case 'W':

0 commit comments

Comments
 (0)