ID: 48709 User updated by: brettz9 at yahoo dot com Reported By: brettz9 at yahoo dot com Status: Closed Bug Type: Unknown/Other Function Operating System: Windows PHP Version: 6CVS-2009-06-28 (snap) Assigned To: felipe New Comment:
Although my patch was indeed better than the previous form, I was mistaken in saying that 'wh' should be pronounced as 'w' per the original algorithm (that is only if the 'w' is followed by a vowel). Although treating 'wh' as 'w' (as you have it now) may indeed be more in the spirit of how metaphone() generally works, if you wish to have fidelity with the original algorithm such as implemented in Basic at http://aspell.net/metaphone/metaphone.basic (and as implemented on other systems), I think you would need to drop this handling. So, to follow the original algorithm, it seems to me that the entire case for 'W' should be removed (line 230 in the previous snapshot). But if you don't care about consistency with other original-based implementations (the Perl one added its own rules, including this one), then my previous patch should be kept. My apologies for the confusion. Previous Comments: ------------------------------------------------------------------------ [2009-06-28 18:45:44] fel...@php.net This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Fixed in 5.2 and HEAD. 5.3 in soon. Thanks. ------------------------------------------------------------------------ [2009-06-28 05:29:41] 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48709&edit=1