summaryrefslogtreecommitdiff
path: root/doc/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2008-04-03 21:13:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2008-04-03 21:13:07 +0000
commit55f6e5f689d3bd086fe4fdcdc823c655005e4d88 (patch)
tree0ddce1855ca7e121ad284f7b3dacba09f0ce160d /doc/src
parentbbe48195ab3e9939d6d414b9db576b7a3edebdda (diff)
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.
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/sgml/fuzzystrmatch.sgml16
1 files changed, 13 insertions, 3 deletions
diff --git a/doc/src/sgml/fuzzystrmatch.sgml b/doc/src/sgml/fuzzystrmatch.sgml
index 1eb1ad61843..62ab943ff7d 100644
--- a/doc/src/sgml/fuzzystrmatch.sgml
+++ b/doc/src/sgml/fuzzystrmatch.sgml
@@ -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') &gt; 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>