]> gitweb.factorcode.org Git - factor.git/blob - basis/lcs/lcs-docs.factor
Fix permission bits
[factor.git] / basis / lcs / lcs-docs.factor
1 USING: help.syntax help.markup ;\r
2 IN: lcs\r
3 \r
4 HELP: levenshtein\r
5 { $values { "old" "a sequence" } { "new" "a sequence" } { "n" "the Levenshtein distance" } }\r
6 { $description "Calculates the Levenshtein distance between old and new, that is, the minimal number of changes from the old sequence to the new one, in terms of deleting, inserting and replacing characters." } ;\r
7 \r
8 HELP: lcs\r
9 { $values { "seq1" "a sequence" } { "seq2" "a sequence" } { "lcs" "a longest common subsequence" } }\r
10 { $description "Given two sequences, calculates a longest common subsequence between them. Note two things: this is only one of the many possible LCSs, and the LCS may not be contiguous." } ;\r
11 \r
12 HELP: diff\r
13 { $values { "old" "a sequence" } { "new" "a sequence" } { "diff" "an edit script" } }\r
14 { $description "Given two sequences, find a minimal edit script from the old to the new. There may be more than one minimal edit script, and this chooses one arbitrarily. This script is in the form of an array of the tuples of the classes " { $link retain } ", " { $link delete } " and " { $link insert } " which have their information stored in the 'item' slot." } ;\r
15 \r
16 HELP: retain\r
17 { $class-description "Represents an action in an edit script where an item is kept, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is retained" } ;\r
18 \r
19 HELP: delete\r
20 { $class-description "Represents an action in an edit script where an item is deleted, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is deleted" } ;\r
21 \r
22 HELP: insert\r
23 { $class-description "Represents an action in an edit script where an item is added, going from the initial sequence to the final sequence. This has one slot, called item, containing the thing which is inserted" } ;\r
24 \r
25 ARTICLE: "lcs" "LCS, diffing and distance"\r
26 "This vocabulary provides words for three apparently unrelated but in fact very similar problems: finding a longest common subsequence between two sequences, getting a minimal edit script (diff) between two sequences, and calculating the Levenshtein distance between two sequences. The implementations of these algorithms are very closely related, and all running times are O(nm), where n and m are the lengths of the input sequences."\r
27 { $subsection lcs }\r
28 { $subsection diff }\r
29 { $subsection levenshtein }\r
30 "The " { $link diff } " word returns a sequence of tuples of the following classes. They all hold their contents in the 'item' slot."\r
31 { $subsection insert }\r
32 { $subsection delete }\r
33 { $subsection retain } ;\r
34 \r
35 ABOUT: "lcs"\r