]> gitweb.factorcode.org Git - factor.git/blob - basis/tools/completion/completion-docs.factor
factor: trim more using lists.
[factor.git] / basis / tools / completion / completion-docs.factor
1 USING: help.markup help.syntax make math strings vectors ;
2 IN: tools.completion
3
4 ARTICLE: "tools.completion" "Fuzzy completion"
5 "Various developer tools make use of a general-purpose fuzzy completion algorithm."
6 $nl
7 "The main entry point:"
8 { $subsections completions }
9 "The words used to implement the algorithm can be called as well, for finer control over fuzzy matching:"
10 { $subsections
11     fuzzy
12     runs
13     score
14     complete
15     rank-completions
16 } ;
17
18 ABOUT: "tools.completion"
19
20 HELP: fuzzy
21 { $values { "full" string } { "short" string } { "indices" vector } }
22 { $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 } "." } ;
23
24 HELP: runs
25 { $values { "seq" "a sequence of integers" } { "newseq" "a sequence of sequences of integers" } }
26 { $description "Groups subsequences of consecutive integers." }
27 { $examples
28     { $example "USING: prettyprint sequences tools.completion ;" "{ 1 2 3 5 6 9 10 } runs [ { } like ] map ." "{ { 1 2 3 } { 5 6 } { 9 10 } }" }
29 } ;
30
31 HELP: score
32 { $values { "full" string } { "fuzzy" "a sequence of sequences of integers" } { "n" integer } }
33 { $description "Ranks " { $snippet "fuzzy" } " by how closely it approximates the sequence " { $snippet "{ { 0 ... n-1 } }" } " where " { $snippet "n" } " is the length of " { $snippet "full" } "." } ;
34
35 HELP: rank-completions
36 { $values { "results" "an alist" } { "newresults" "an alist" } }
37 { $description "Sorts " { $snippet "results" } " by the first element of each pair, and discards the low 33% of the results." } ;
38
39 HELP: complete
40 { $values { "full" string } { "short" string } { "score" "a rational number between 0 and 1" } }
41 { $description "Ranks how close " { $snippet "short" } " is to " { $snippet "full" } " by edit distance." } ;
42
43 HELP: completion
44 { $values { "short" string } { "candidate" "a pair " { $snippet "{ obj full }" } } { "score" number } }
45 { $description "Outputs a score for matching two elements indicating how close " { $snippet "short" } " is to " { $snippet "full" } " by edit distance" } ;
46
47 HELP: completion,
48 { $values { "short" string } { "candidate" "a pair " { $snippet "{ obj full }" } } }
49 { $description
50     "Adds the result of " { $link completion }
51     " to the end of the sequence being constructed by " { $link make }
52     " if the score is positive."
53 } ;
54
55 HELP: completions
56 { $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 }" } } }
57 { $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%." } ;