]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/completion/completion-docs.factor
Create basis vocab root
[factor.git] / basis / tools / completion / completion-docs.factor
1 USING: help.markup help.syntax strings generic vectors assocs
2 math ;
3 IN: tools.completion
4
5 ARTICLE: "tools.completion" "Fuzzy completion"
6 "Various developer tools make use of a general-purpose fuzzy completion algorithm."
7 $nl
8 "The main entry point:"
9 { $subsection completions }
10 "The words used to implement the algorithm can be called as well, for finer control over fuzzy matching:"
11 { $subsection fuzzy }
12 { $subsection runs }
13 { $subsection score }
14 { $subsection complete }
15 { $subsection rank-completions } ;
16
17 ABOUT: "tools.completion"
18
19 HELP: fuzzy
20 { $values { "full" string } { "short" string } { "indices" vector } }
21 { $description "If " { $snippet "short" } " can be obtained from " { $snippet "full" } " by removing subsequences, then outputs the index of every character from " { $snippet "short" } " in " { $snippet "full" } ", otherwise outputs " { $link f } "." } ;
22
23 HELP: runs
24 { $values { "seq" "a sequence of integers" } { "newseq" "a sequence of sequences of integers" } }
25 { $description "Groups subsequences of consecutive integers." }
26 { $examples
27     { $example "USING: prettyprint tools.completion ;" "{ 1 2 3 5 6 9 10 } runs ." "V{ V{ 1 2 3 } V{ 5 6 } V{ 9 10 } }" }
28 } ;
29
30 HELP: score
31 { $values { "full" string } { "fuzzy" "a sequence of sequences of integers" } { "n" integer } }
32 { $description "Ranks " { $snippet "fuzzy" } " by how closely it approximates the sequence " { $snippet "{ { 0 ... n-1 } }" } " where " { $snippet "n" } " is the length of " { $snippet "full" } "." } ;
33
34 HELP: rank-completions
35 { $values { "results" "an alist" } { "newresults" "an alist" } }
36 { $description "Sorts " { $snippet "results" } " by the first element of each pair, and discards the low 33% of the results." } ;
37
38 HELP: complete
39 { $values { "full" string } { "short" string } { "score" "a rational number between 0 and 1" } }
40 { $description "Ranks how close " { $snippet "short" } " is to " { $snippet "full" } " by edit distance." } ;
41
42 HELP: completion
43 { $values { "short" string } { "candidate" "a pair " { $snippet "{ obj full }" } } { "result" "a pair " { $snippet "{ score obj }" } } }
44 { $description "Outputs a pair of two elements:"
45     { $list
46         { "how close " { $snippet "short" } " is to " { $snippet "full" } " by edit distance" }
47         { "the original value of " { $snippet "obj" } }
48     }
49 } ;
50
51 HELP: completions
52 { $values { "short" string } { "candidates" "a sequence of pairs of the shape " { $snippet "{ obj full }" } } { "seq" "a sequence of pairs of the shape " { $snippet "{ score obj }" } } }
53 { $description "Calls " { $link completion } " to produce a sequence of " { $snippet "{ score obj }" } " pairs, then calls " { $link rank-completions } " to sort them and discard the low 33%." } ;