ID:               48711
 Comment by:       brettz9 at yahoo dot com
 Reported By:      brettz9 at yahoo dot com
 Status:           Open
 Bug Type:         Unknown/Other Function
 Operating System: Windows
 PHP Version:      6CVS-2009-06-29 (snap)
 New Comment:

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):


Previous Comments:
------------------------------------------------------------------------

[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/?id=48711&edit=1

Reply via email to