Permalink
Browse files

Merge pull request #40 from nol888/gh-pages

Add Levenshtein distance algorithm documetation.
  • Loading branch information...
2 parents f12b923 + 060c6d2 commit 701b09823452958e7180f05323dbe522cb10c4f8 @Whiteknight committed Dec 19, 2011
Showing with 23 additions and 0 deletions.
  1. +23 −0 libraries/string.md
View
@@ -56,6 +56,29 @@ Here are some examples of string utilities:
s = pad_end("test", 6); # "test "
s = replace("banana", "a", "X"); # "bXnXnX"
+Rosella also provides selected metrics which compare two strings. One of the
+provided algorithms is the Levenshtein distance `String.distance(s1, s2)`.
+The Levenshtein distance between two strings is defined as the minimum number
+of edits needed to transform one string into the other, with the allowable edit
+operations being insertion, deletion, or substitution of a single character.
+
+A quick example of the function and return values:
+
+ i = distance("purl", "perl"); # 1
+ i = distance("Saturday", "Sunday"); # 3 (Saturday -> Sturday,
+ Sturday -> Surday, Surday -> Sunday)
+ i = distance("kitten", "sitting"); # 3 (kitten -> sitten,
+ sitten -> sittin, sittin -> sitting)
+
+## Functions
+
+### String.distance
+
+The String.distance function provides a simple implementation to compute the
+Levenshtein distance between two strings.
+
+An example of
+
## Classes
### String.Tokenizer

0 comments on commit 701b098

Please sign in to comment.