Re: BUG #18654: From fuzzystrmatch, levenshtein function with costs parameters produce incorrect results

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: bjdev(dot)gthb(at)laposte(dot)net
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #18654: From fuzzystrmatch, levenshtein function with costs parameters produce incorrect results
Date: 2024-10-14 16:01:03
Message-ID: 3737494.1728921663@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> But if we use this function with parameters other than 1 (the default) the
> result is incorrect

> SELECT levenshtein('horses','shorse',1,1,1) => 2 (correct)

> SELECT levenshtein('horses','shorse',100,10,1) => 101 (INCORRECT)
> The correct result is 6 (all the letter have to be substitute and it's not
> possible to have a lower score with others operations)

Hmm, works for me:

u8=# create extension fuzzystrmatch;
CREATE EXTENSION
u8=# SELECT levenshtein('horses','shorse',1,1,1);
levenshtein
-------------
2
(1 row)

u8=# SELECT levenshtein('horses','shorse',100,10,1);
levenshtein
-------------
6
(1 row)

I confess bafflement about why you're getting wrong answers.
You seem to be using a slightly out of date Postgres, but
none of this code has changed meaningfully since about 2016.
Maybe you hit a compiler bug? Where did you get this copy
of Postgres from --- or if you built it yourself, what build
options did you use?

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Bruce Momjian 2024-10-14 21:52:59 Re: BUG #18614: [ECPG] out of bound in DecodeDateTime
Previous Message Maxim Boguk 2024-10-14 12:33:03 Re: BUG #18644: ALTER PUBLICATION ... SET (publish_via_partition_root) wrong/undocumented behavior.