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
syntax:functions:distance [2018/03/01 09:24] dmitrysyntax:functions:distance [2021/08/14 22:02] (current) – [Examples] 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 character insertion or deletion is needed to produce 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" |  | + 
-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"//Returns  (Strings are the same) 
 + 
 +  distance("cat", "cut"//Returns  (Change "a" to "u") 
 + 
 +  distance("cat", "dog"//Returns  (Change "c" to "d", "a" to "o", and "t" to "g") 
 + 
 +  distance("cat", "Scott"//Returns 3  (Delete "S" and one of the "t"s, and change "a" to "o"
 + 
 +  distance("Mary","mary") //Returns 1  (Replace upper-case "M" with lower-case "m"
 + 
 +  distance(100, 1) //Returns 2  (Remove both "0"s) 
 + 
 +  distance(100, "Bob") //Returns  (Replace "1" with "M", replace "0" with "a", and replace "0" with "r")
  
-Use cases: fuzzy matching, detection of mistyped words. 
syntax/functions/distance.1519914269.txt.gz · Last modified: 2018/03/01 09:24 by dmitry

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki