mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Add a variant of the Levenshtein string-distance function that lets the user
specify the cost values to use, instead of always using 1's. Volkan Yazici In passing, remove fuzzystrmatch.h, which contained a bunch of stuff that had no business being in a .h file; fold it into its only user, fuzzystrmatch.c.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/fuzzystrmatch.sgml,v 1.3 2007/12/06 04:12:10 tgl Exp $ -->
|
||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/fuzzystrmatch.sgml,v 1.4 2008/04/03 21:13:07 tgl Exp $ -->
|
||||
|
||||
<sect1 id="fuzzystrmatch">
|
||||
<title>fuzzystrmatch</title>
|
||||
@ -74,16 +74,20 @@ SELECT * FROM s WHERE difference(s.nm, 'john') > 2;
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
levenshtein(text source, text target, int ins_cost, int del_cost, int sub_cost) returns int
|
||||
levenshtein(text source, text target) returns int
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
Both <literal>source</literal> and <literal>target</literal> can be any
|
||||
non-null string, with a maximum of 255 characters.
|
||||
non-null string, with a maximum of 255 bytes. The cost parameters
|
||||
specify how much to charge for a character insertion, deletion, or
|
||||
substitution, respectively. You can omit the cost parameters, as in
|
||||
the second version of the function; in that case they all default to 1.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Example:
|
||||
Examples:
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
@ -92,6 +96,12 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL');
|
||||
-------------
|
||||
2
|
||||
(1 row)
|
||||
|
||||
test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1);
|
||||
levenshtein
|
||||
-------------
|
||||
3
|
||||
(1 row)
|
||||
</programlisting>
|
||||
</sect2>
|
||||
|
||||
|
Reference in New Issue
Block a user