java.lang.Object
org.egothor.stemmer.Trie
- Direct Known Subclasses:
MultiTrie
A Trie is used to store a dictionary of words and their stems.
Actually, what is stored are words with their respective patch commands. A trie can be termed forward (keys read from left to right) or backward (keys read from right to left). This property will vary depending on the language for which a Trie is constructed.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) class
This class is part of the Egothor Project -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
add
(CharSequence key, CharSequence cmd) Add the given key associated with the given patch command.getAll
(CharSequence key) Gets the all attribute of the Trie objectint
getCells()
Return the number of cells in this Trie object.int
Gets the cellsPnt attribute of the Trie objectint
Gets the cellsVal attribute of the Trie objectgetFully
(CharSequence key) Return the element that is stored in a cell associated with the given key.Return the element that is stored as last on a path associated with the given key.private Row
getRow
(int index) Return the Row at the given index.void
printInfo
(PrintStream out, CharSequence prefix) writes debugging info to the printstreamRemove empty rows from the given Trie and return the newly reduced Trie.void
store
(DataOutput os) Write this Trie to the given output stream.
-
Field Details
-
rows
-
cmds
List<CharSequence> cmds -
root
int root -
forward
boolean forward
-
-
Constructor Details
-
Trie
Constructor for the Trie object.- Parameters:
is
- the input stream- Throws:
IOException
- if an I/O error occurs
-
Trie
public Trie(boolean forward) Constructor for the Trie object.- Parameters:
forward
- set totrue
-
Trie
Constructor for the Trie object.- Parameters:
forward
-true
if read left to right,false
if read right to leftroot
- index of the row that is the root nodecmds
- the patch commands to storerows
- a Vector of Vectors. Each inner Vector is a node of this Trie
-
-
Method Details
-
getAll
Gets the all attribute of the Trie object- Parameters:
key
- Description of the Parameter- Returns:
- The all value
-
getCells
public int getCells()Return the number of cells in this Trie object.- Returns:
- the number of cells
-
getCellsPnt
public int getCellsPnt()Gets the cellsPnt attribute of the Trie object- Returns:
- The cellsPnt value
-
getCellsVal
public int getCellsVal()Gets the cellsVal attribute of the Trie object- Returns:
- The cellsVal value
-
getFully
Return the element that is stored in a cell associated with the given key.- Parameters:
key
- the key- Returns:
- the associated element
-
getLastOnPath
Return the element that is stored as last on a path associated with the given key.- Parameters:
key
- the key associated with the desired element- Returns:
- the last on path element
-
getRow
Return the Row at the given index.- Parameters:
index
- the index containing the desired Row- Returns:
- the Row
-
store
Write this Trie to the given output stream.- Parameters:
os
- the output stream- Throws:
IOException
- if an I/O error occurs
-
add
Add the given key associated with the given patch command. If either parameter is null this method will return without executing.- Parameters:
key
- the keycmd
- the patch command
-
reduce
Remove empty rows from the given Trie and return the newly reduced Trie.- Parameters:
by
- the Trie to reduce- Returns:
- the newly reduced Trie
-
printInfo
writes debugging info to the printstream
-