1 ! Copyright (C) 2008 Marc Fauconneau.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays help.markup help.syntax io.streams.string
4 sequences strings math suffix-arrays.private ;
11 { $description "Creates a suffix array from the input sequence. Suffix arrays are arrays of slices." } ;
14 { $description "Creates a new literal suffix array at parse-time." } ;
19 { "suffixes-seq" "a sequence of slices" } }
20 { $description "Returns a sequence of tail slices of the input string." } ;
24 { "index" integer } { "begin" sequence } { "suffix-array" "a suffix-array" }
25 { "from/f" "an integer or f" } { "to/f" "an integer or f" } }
26 { $description "Finds the bounds of the suffix array that match the input sequence. A return value of " { $link f } " means that the endpoint is included." }
27 { $notes "Slices are [m,n) and we want (m,n) so we increment." } ;
31 { "begin" sequence } { "suffix-array" "a suffix-array" }
33 { $description "Returns a sequence of sequences from the suffix-array that contain the input sequence. An empty array is returned when there are no matches." } ;
35 ARTICLE: "suffix-arrays" "Suffix arrays"
36 "The " { $vocab-link "suffix-arrays" } " vocabulary implements the suffix array data structure for efficient lookup of subsequences. This suffix array implementation is a sorted array of suffixes. Querying it for matches uses binary search for efficiency." $nl
38 "Creating new suffix arrays:"
39 { $subsection >suffix-array }
40 "Literal suffix arrays:"
41 { $subsection POSTPONE: SA{ }
42 "Querying suffix arrays:"
43 { $subsection query } ;
45 ABOUT: "suffix-arrays"