2008-10-01 15:19:28 -04:00
! Copyright (C) 2008 Marc Fauconneau.
! See http://factorcode.org/license.txt for BSD license.
USING: arrays help.markup help.syntax io.streams.string
2008-10-01 15:49:21 -04:00
sequences strings math suffix-arrays.private ;
2008-10-01 15:19:28 -04:00
IN: suffix-arrays
HELP: >suffix-array
{ $values
{ "seq" sequence }
{ "array" array } }
2017-06-05 13:13:54 -04:00
{ $description "Creates a suffix array from the input sequence. Suffix arrays are arrays of slices." } ;
2008-10-01 15:19:28 -04:00
HELP: SA{
{ $description "Creates a new literal suffix array at parse-time." } ;
HELP: suffixes
{ $values
{ "string" string }
{ "suffixes-seq" "a sequence of slices" } }
{ $description "Returns a sequence of tail slices of the input string." } ;
HELP: query
{ $values
2008-10-01 17:00:23 -04:00
{ "begin" sequence } { "suffix-array" "a suffix-array" }
2008-10-01 15:19:28 -04:00
{ "matches" array } }
2008-10-01 17:00:23 -04:00
{ $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." } ;
2008-10-01 15:19:28 -04:00
ARTICLE: "suffix-arrays" "Suffix arrays"
2008-10-01 15:49:21 -04:00
"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
2008-10-01 15:19:28 -04:00
"Creating new suffix arrays:"
2009-10-01 15:56:36 -04:00
{ $subsections >suffix-array }
2008-10-01 15:19:28 -04:00
"Literal suffix arrays:"
2009-10-01 15:56:36 -04:00
{ $subsections POSTPONE: SA{ }
2008-10-01 15:19:28 -04:00
"Querying suffix arrays:"
2009-10-01 15:56:36 -04:00
{ $subsections query } ;
2008-10-01 15:19:28 -04:00
ABOUT: "suffix-arrays"