<p>These functions calculate the Levenshtein distance between two strings: </p>
<codeblock>levenshtein(text <varname>source</varname>, text <varname>target</varname>, int <varname>ins_cost</varname>, int <varname>del_cost</varname>, int <varname>sub_cost</varname>) returns int
levenshtein(text <varname>source</varname>, text <varname>target</varname>) returns int
levenshtein_less_equal(text <varname>source</varname>, text <varname>target</varname>, int <varname>ins_cost</varname>, int <varname>del_cost</varname>, int <varname>sub_cost</varname>, int <varname>max_d</varname>) returns int
levenshtein_less_equal(text <varname>source</varname>, text <varname>target</varname>, int max_d) returns int</codeblock>
<p>Both the <codeph>source</codeph> and <codeph>target</codeph> parameters can be any
non-null string, with a maximum of 255 bytes. The cost parameters
<codeph>ins_cost</codeph>, <codeph>del_cost</codeph>, and <codeph>sub_cost</codeph>
specify cost of a character insertion, deletion, or substitution, respectively. You can
omit the cost parameters, as in the second version of the function; in that case the cost
parameters default to 1.</p>
<p>
<apiname>levenshtein_less_equal</apiname> is accelerated version of
<apiname>levenshtein</apiname> function for low values of distance. If actual distance
is less or equal then <codeph>max_d</codeph>, then
<apiname>levenshtein_less_equal</apiname> returns an accurate value of the distance.
Otherwise, this function returns value which is greater than <codeph>max_d</codeph>.