From 55f6e5f689d3bd086fe4fdcdc823c655005e4d88 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 3 Apr 2008 21:13:07 +0000 Subject: 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. --- doc/src/sgml/fuzzystrmatch.sgml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'doc/src') 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 @@ - + fuzzystrmatch @@ -74,16 +74,20 @@ SELECT * FROM s WHERE difference(s.nm, 'john') > 2; + levenshtein(text source, text target, int ins_cost, int del_cost, int sub_cost) returns int levenshtein(text source, text target) returns int Both source and target 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. - Example: + Examples: @@ -92,6 +96,12 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL'); ------------- 2 (1 row) + +test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1); + levenshtein +------------- + 3 +(1 row) -- cgit v1.2.3