#31188 [Bgs]: metaphone function returns incorrect results
ID: 31188
Updated by: amt@php.net
Reported By: travis at dreamsage dot com
Status: Bogus
Bug Type: Strings related
Operating System: Windows XP (linux untested)
PHP Version: 4.3.9
New Comment:
From reading Schwern's man page, it appears that there was
an original BASIC version from 1990 and then a C version in
1995. It also appears that Schwern made a few custom
improvements on the original algorithm. I don't know which
version made it into PHP.
http://search.cpan.org/~mschwern/Text-Metaphone-1.96/
Metaphone.pm
If you can demonstrate that somehow the PHP version is
different than the Perl version, then that would probably be
actionable, but outside of that, I don't think anyone is
going to look into the algorithm.
Previous Comments:
------------------------------------------------------------------------
[2004-12-20 00:55:01] travis at dreamsage dot com
if the code has been rewritten for version 5 then I don't know if
there's a problem in that version. I have only tested 4.3 where there
is a problem. Also, I certainly don't think VB is better than PHP. It's
for my job and sometimes they make me do things that I don't want to
do.
anyway, I ran through the "a"s and found some that should describe the
problem. Listed is the word then the php string then what it should
be.
the g should be silent
Agnail - AKNL - ANL
the b should not be silent
Alembic - ALMK - ALMB
the h should be silent
Afghan - AFFN - AFKN
the x is misplaced
Ascian - ASXN - ASN
Also, PHP has a problem returning more than the number of chars you ask
it to return on very rare occasions. If I ask it to return 4 chars it
will return 5 every maybe 400 times.
And you're right, the original was written in 95 and not 90. My mistake
there, I was writing from memory.
this is the java version and seems to work nicely to test on.
http://www.wbrogden.com/phonetic/index.html
Thanks
Travis
------------------------------------------------------------------------
[2004-12-20 00:34:59] derick@php.net
Our documentation (http://nl.php.net/metaphone) states that " Metaphone
was developed by Lawrence Philips <lphilips at verity dot com>. It is
described in ["Practical Algorithms for Programmers", Binstock & Rex,
Addison Wesley, 1995]. " so your "original" basic code can not have
anything to do with the implementation we use. Therefore this is not a
bug, just a slightly different algorithm.
------------------------------------------------------------------------
[2004-12-20 00:28:42] jed@php.net
I bogused you because it sounded like a simple "VB does this right, PHP
doesn't", which doesn't really say anything. You're serious, though, so
I apologize for the quick bogus.
We can't fix this without a lot more information. We need a valid test
case to examine a specific fault before we can even move on this.
Simply saying "some of these are wrong" doesn't help us at all, and as
a result, we can't help you.
You gave us some letters that confuse our metaphone, so let's work with
that -- do you have a specific word that is metaphoned differently? The
implementation, in PHP 5 at least, is based on CPAN's
"Text-Metaphone-1.96" by Michael G Schwern according to the source.
Thanks again.
------------------------------------------------------------------------
[2004-12-19 23:37:23] travis at dreamsage dot com
I have checked my VB against results from the original Basic version, a
C version as well as a commonly used Java version and the PHP version
gives different results than any of these. You have a bug here. Please
don't ignore this. The metaphone code commonly runs spellchecks for
many MANY websites. The code that controls this is only a couple
hundred lines long and so it shouldn't take long to fix.
Travis
------------------------------------------------------------------------
[2004-12-19 23:00:28] jed@php.net
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.
Thank you for your interest in PHP.
Perhaps your VB is wrong? We can\'t do anything about this without a
lot more information.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/31188
--
Edit this bug report at http://bugs.php.net/?id=31188&edit=1
Thread (7 messages)