\seekquarry\yioop\libraryTrie

Implements a trie data structure which can be used to store terms read from a dictionary in a succinct way

Summary

Methods
Properties
Constants
__construct()
add()
exists()
getValues()
$trie_array
$end_marker
No constants found
No protected methods found
No protected properties found
N/A
getValuesTrieArray()
No private properties found
N/A

Properties

$trie_array

$trie_array : array

A nested array used to represent the trie

Type

array

$end_marker

$end_marker : string

The marker used to represent the end of an entry in a trie

Type

string

Methods

__construct()

__construct(string  $end_marker = " ") 

Creates and returnes an empty trie. Sets the end of term character

Parameters

string $end_marker

end of term marker

add()

add(string  $term, boolean  $raw_url_decode = true) : array

Adds a term to the Trie

Parameters

string $term

the term to be inserted if a space separated term value pair. Then the term is inserted into the trie and the leaf label is the value.

boolean $raw_url_decode

decide term should be encoded in utf-8 or url

Returns

array —

$trie_array beneath last letter of term inserted

exists()

exists(string  $term) : array

Returns the sub trie_array under $term in $this->trie_array. If $term does not exist in $trie->trie_array returns false

Parameters

string $term

term to look up

Returns

array —

$trie_array subtrie under term

getValues()

getValues(string  $prefix, integer  $max_results) : array

Returns all the terms in the trie beneath the provided term prefix

Parameters

string $prefix

of term to look up

integer $max_results

maximum number of strings to return

Returns

array —

$terms under $prefix

getValuesTrieArray()

getValuesTrieArray(array  $trie_array, string  $prefix, integer  $max_results, integer  $count, boolean  $find_more = true) : array

Computes the suffixes $count,.

..$max_results-$count in the trie_array beneath the provided $find_more is true. Prepends $prefix to each and returns the array of the result.

Parameters

array $trie_array

a nested array representing a trie to look up suffixes in

string $prefix

to prepend to each found suffix

integer $max_results

maximum number of strings to return

integer $count

which suffix in trie_array to start with

boolean $find_more

whether to try to look up or not (stops recursion)

Returns

array —

$terms a list of ($prefix.suffix1, $prefix, $suffix2,...)