]> granicus.if.org Git - postgresql/commit
Jim C. Nasby wrote:
authorBruce Momjian <bruce@momjian.us>
Tue, 24 Jun 2003 22:59:46 +0000 (22:59 +0000)
committerBruce Momjian <bruce@momjian.us>
Tue, 24 Jun 2003 22:59:46 +0000 (22:59 +0000)
commit7b1f6ffaabc8f538c82b94a5fc664941f4ff0b70
tree935674b49b8381b8d799ff3274acbff101d70b5d
parent4b1fe23153430618359b635f3550265d394bc20a
Jim C. Nasby wrote:
> Second argument to metaphone is suposed to set the limit on the
> number of characters to return, but it breaks on some phrases:
>
> usps=# select metaphone(a,3),metaphone(a,4),metaphone(a,20) from
> (select 'Hello world'::varchar AS a) a;
> HLW       | HLWR      | HLWRLT
>
> usps=# select metaphone(a,3),metaphone(a,4),metaphone(a,20) from
> (select 'A A COMEAUX MEMORIAL'::varchar AS a) a;
  > AKM       | AKMKS     | AKMKSMMRL
>
> In every case I've found that does this, the 4th and 5th letters are
> always 'KS'.

Nice catch.

There was a bug in the original metaphone algorithm from CPAN. Patch
attached (while I was at it I updated my email address, changed the
copyright to PGDG, and removed an unnecessary palloc). Here's how it
looks now:

regression=# select metaphone(a,4) from (select 'A A COMEAUX
MEMORIAL'::varchar AS a) a;
   metaphone
-----------
   AKMK
(1 row)

regression=# select metaphone(a,5) from (select 'A A COMEAUX
MEMORIAL'::varchar AS a) a;
   metaphone
-----------
   AKMKS
(1 row)

Joe Conway
contrib/fuzzystrmatch/README.fuzzystrmatch
contrib/fuzzystrmatch/fuzzystrmatch.c
contrib/fuzzystrmatch/fuzzystrmatch.h