Edit report at http://bugs.php.net/bug.php?id=48711&edit=1
ID: 48711 Comment by: jthijssen at noxlogic dot nl Reported by: brettz9 at yahoo dot com Summary: metaphone() and sch, ch, gh Status: No Feedback Type: Bug Package: Strings related Operating System: Windows PHP Version: 6CVS-2009-06-29 (snap) Block user comment: N Private report: N New Comment: I've added a patch with the 4 items as described by brettz9. The first one introduces a "traditional" boolean flag in metaphone as a third optional parameter. I'm not 100% sure why this parameter is here. Either we should always convert CHR/SCH to X or to K. It makes the function much more complicated this way for end-users. Previous Comments: ------------------------------------------------------------------------ [2009-08-03 01:00:02] php-bugs at lists dot php dot net No feedback was provided for this bug for over a week, so it is being suspended automatically. If you are able to provide the information that was originally requested, please do so and change the status of the bug back to "Open". ------------------------------------------------------------------------ [2009-07-26 19:36:59] j...@php.net Please provide patches against all current branches, I don't think this is just an issue with HEAD? ------------------------------------------------------------------------ [2009-06-29 04:06:33] brettz9 at yahoo dot com My apologies, I was off by one line number in item #4; it should instead say: inside the first 'if' of the 2nd 'G' case (insert right after line 342): ------------------------------------------------------------------------ [2009-06-29 04:00:29] brettz9 at yahoo dot com Description: ------------ Below are a few bugs remaining in metaphone()--they are both useful and follow the original implementation. I haven't tested them (a newbie to C), but they seem to follow the precise pattern. 1) SCH: There seems to be no way for the 'traditional' argument in metaphone() to be triggered (it is called on line 44 with '1' which disables those items depending on it). Shouldn't it be set to '0' in the call on line 44 (or have the requirement removed entirely)? For example, line 314 is not working now for treating items like "ch" in "school" as "K". If there's no way to trigger the behavior (and the behavior should be standard), it seems to me best to remove the requirement. 2) CH: should check for first position 'C': if the next char is 'H' and then a vowel, it should produce 'K' To fix, in the switch beginning at 205 for initial character (e.g., could put before 219): case 'C': if (Next_Letter == 'H' && isvowel(After_Next_Letter)) { // 'character' Phonize('K'); w_idx += 2; } break; 3) GH: should be pronounced as 'K' if at the beginning (and if then followed by a vowel), not as 'F'; The case for initial 'G' on line 219 could be changed to: case 'G': if (Next_Letter == 'H' && isvowel(After_Next_Letter)) { // 'ghent' Phonize('K'); w_idx += 2; break; } else 4) GH: should be silent in the likes of 'knight'/'wright', not 'F' under the 2nd 'G' case (insert right after line 341): if (After_Next_Letter != '\0' && !isvowel(After_Next_Letter) { // 'gh' followed by consonant, as in 'knight' /* silent */ } else Thanks! Reproduce code: --------------- <?php echo metaphone('school'), '<br />'; echo metaphone('character'), '<br />'; echo metaphone('ghent'), '<br />'; echo metaphone('knight'), '<br />'; ?> Expected result: ---------------- SKL KRKTR KNT NT Actual result: -------------- SXL XRKTR FNT NFT ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=48711&edit=1