Skip to content

Commit

Permalink
Merge pull request #40 from nol888/gh-pages
Browse files Browse the repository at this point in the history
Add Levenshtein distance algorithm documetation.
  • Loading branch information
Whiteknight committed Dec 19, 2011
2 parents f12b923 + 060c6d2 commit 701b098
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions libraries/string.md
Expand Up @@ -56,6 +56,29 @@ Here are some examples of string utilities:
s = pad_end("test", 6); # "test " s = pad_end("test", 6); # "test "
s = replace("banana", "a", "X"); # "bXnXnX" 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 ## Classes


### String.Tokenizer ### String.Tokenizer
Expand Down

0 comments on commit 701b098

Please sign in to comment.