User Tools

Site Tools


syntax:functions:distance

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
syntax:functions:distance [2018/03/01 09:23] dmitrysyntax:functions:distance [2021/08/01 19:59] craigt
Line 1: Line 1:
-===== distance(texttext) =====+====== Distance(text1text2) =====
 +Category:  Text function
  
-The edit distance between two text strings calculated as the [[https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance|Damerau-Levenshtein distance]]. It shows the number of text edits such as insert or delete are needed to obtain one text string from another. It's used to measure a degree of variance between two strings. The bigger is the edit distance, the more different the strings are+\\  
 +=====Description===== 
 +This function returns the edit distance between two text strings calculated as the [[https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance|Damerau-Levenshtein distance]]. 
  
- Example   Result  +This shows the number of text edits, such as character insertions or deletions, that is needed to produce //text2// from //text1//. It is used to measure the degree of variance between two strings. The larger the edit distance, the more different the strings are.  
-| distance("cat", "cat")   0 | + 
-distance("cat", "cut" |  | +\\  
-distance("cat", "dog" |  | +=====Use cases==== 
-distance("cat", "Scott")   |+Rating the similarity between words (fuzzy matching). 
 + 
 +The detection of mistyped words. 
 + 
 +\\  
 +=====Arguments===== 
 +^Argument^Type^Description
 +|text1|Text|The "source" string value.| 
 +|text2|Text|The "destination" string to transform //text1// into .| 
 + 
 +**Return value type:** Number 
 + 
 +\\  
 +=====Remarks===== 
 +This function is case sensitive insofar as replacing a lower-case character with the upper-case version, or upper-case with the lower-case version, is considered an edit. 
 + 
 +While numeric values can be entered for either argument, the function handles them as text strings for the calculation of the edit distance. 
 + 
 +\\  
 +=====Examples===== 
 + 
 +  distance("cat", "cat"= 0  //Strings are the same 
 +  distance("cat", "cut" //Change "a" to "u" 
 +  distance("cat", "dog" //Change "c" to "d", "a" to "o", and "t" to "g" 
 +  distance("cat", "Scott"= 3  //Delete "S" and one of the "t"s, and change "a" to "o" 
 +  distance("Mary","mary") = 1  //Replace upper-case "M" with lower-case "m" 
 +  distance(100, 1) = 2  //Remove both "0"
 +  distance(100, "Bob") =  //Replace "1" with "M", replace "0" with "a", and replace "0" with "r"
  
-Use cases: fuzzy matching, detection of mistyped words. 
syntax/functions/distance.txt · Last modified: 2021/08/14 22:02 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki