PHP :: Bug #48709 :: metaphone and 'wh'
| Bug #48709 | metaphone and 'wh' | ||||
|---|---|---|---|---|---|
| Submitted: | 2009-06-28 05:29 UTC | Modified: | 2009-06-29 03:35 UTC | ||
| From: | brettz9 at yahoo dot com | Assigned: | felipe (profile) | ||
| Status: | Closed | Package: | Unknown/Other Function | ||
| PHP Version: | 5.2, 5.3, 6CVS-2009-06-28 (snap) | OS: | Windows | ||
| Private report: | No | CVE-ID: | None | ||
[2009-06-28 05:29 UTC] brettz9 at yahoo dot com
Description:
------------
The source for metaphone() states in the comments that "WH becomes H" and when one tests it, e.g., with "whit", as per the comment on line 227 and the code which phonizes Next_Letter on line 233 when there is a 'W' followed by 'H', it returns 'H' ("ht" for 'whit').
However, according to the metaphone() algorithm (see http://aspell.net/metaphone/ and the original implementation at http://aspell.net/metaphone/metaphone.basic ), 'wh' should become 'w', not 'h'.
So, to fix it, you could change the comment on 233 to:
/* WH becomes W,
and then change the 'if' on 231-234 to:
if (Next_Letter == 'H') {
Phonize('W');
w_idx += 2;
} else if (Next_Letter == 'R') {
Phonize(Next_Letter);
w_idx += 2;
Reproduce code:
---------------
<?php
echo metaphone('Whit');
?>
Expected result:
----------------
WT
Actual result:
--------------
HT
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2009-06-28 18:45 UTC] felipe@php.net
[2009-06-29 02:50 UTC] brettz9 at yahoo dot com
[2009-06-29 03:32 UTC] felipe@php.net
[2009-06-29 03:35 UTC] brettz9 at yahoo dot com