|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectVariableArrayTrie
An implementation of tries with arrays of variable size. Each node is an array of pointers on its sons. The label is carried by the following node. The size is bounded by the sum of lengths of the nodes. The algorithms are linear in the size of the word times the cardinality of the alphabet. Performances: the trie of the delaf dictionnary (a french dictionnary of all words at all forms -about 1M words) can be computed without memory extension. The result is a trie with about 2M nodes (which indicates that the arity of the nodes is in the avarage close to 2). To transform the trie into an IDFA requires an extension of the stack memory to 120M (using the option -Xmx120m).
| Field Summary | |
char |
label
|
VariableArrayTrie[] |
next
|
int |
num
|
boolean |
terminal
|
| Constructor Summary | |
VariableArrayTrie(char c)
Creates a node with label c. |
|
| Method Summary | |
void |
add(char c)
Adds an entry in the next array to allow a transition
by c. |
void |
addToTrie(java.lang.String s)
Adds the word s to the trie. |
void |
addToTrieBis(java.lang.String s)
A variant of addToTrie(). |
void |
addToTrieTer(java.lang.String s)
A variant of addToTrie(). |
int |
copy(int p,
DFA a)
|
int |
copy(int p,
IDFA a)
|
void |
copybis(DFA a)
|
void |
copybis(IDFA a)
|
int |
enum(int p)
Numbers the nodes of a trie through an initilization of the field num. |
void |
fromFile(java.lang.String name)
Builds a trie representing the list of strings read from a file line by line. |
void |
fromFileBis(java.lang.String name)
Builds a trie representing the list of the reverse of strings read from a file line by line. |
int |
index(char c)
Returns the index of a node with label c if
there is one and -1 otherwise. |
boolean |
isInTrie(java.lang.String s)
Implements the function IsInTrie() of Section 1.3.1. |
boolean |
isLeaf()
Returns true if the node p is a leaf of the trie.
|
Pair |
longestPrefixInTrie(java.lang.String s,
int j)
Computes the pair composed of the length of the longest prefix of s[j..n-1] in the trie and the vertex reached by this prefix. |
static void |
main(java.lang.String[] args)
|
VariableArrayTrie |
next(char c)
Returns the node Next(c) if it exists
and null otherwise. |
void |
remove(int k)
Removes the entry of index k
of the array next. |
void |
removeFromTrie(java.lang.String s)
Removes the string s from the trie. |
int |
size()
Returns the number of nodes of the trie. |
Dawg |
toDawg()
|
DFA |
toDFA(Alphabet alph)
|
DFA |
toDFAbis(Alphabet alph)
|
IDFA |
toIDFA(Alphabet alph)
|
IDFA |
toIDFAbis(Alphabet alph)
Creates an IDFA from a trie. |
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public boolean terminal
public char label
public int num
public VariableArrayTrie[] next
| Constructor Detail |
public VariableArrayTrie(char c)
c.
| Method Detail |
public VariableArrayTrie next(char c)
Next(c) if it exists
and null otherwise.
public int index(char c)
c if
there is one and -1 otherwise.
public void add(char c)
next array to allow a transition
by c.
public void remove(int k)
k
of the array next.
public Pair longestPrefixInTrie(java.lang.String s,
int j)
LongestPrefixInTrie() of Section 1.3.1.
longestPrefixInTrie in interface Tries - the input stringj - the starting index
public boolean isInTrie(java.lang.String s)
IsInTrie() of Section 1.3.1.
isInTrie in interface Triepublic void addToTrie(java.lang.String s)
AddToTrie() of Section 1.3.1.
addToTrie in interface Tries - the string to be addedpublic void addToTrieBis(java.lang.String s)
addToTrie(). Does not
use longestPrefixInTrie() and thus more economical in space (?).
public void addToTrieTer(java.lang.String s)
addToTrie(). Adds the reverse of the
word s
public boolean isLeaf()
p is a leaf of the trie.
Implements
the function IsLeaf() of Section 1.3.1.
isLeaf in interface Triepublic void removeFromTrie(java.lang.String s)
RemoveFromTrie() of Section 1.3.1.
removeFromTrie in interface Tries - the string to be removed
public void fromFile(java.lang.String name)
throws java.io.IOException
fromFile in interface Triename - the name of the file
java.io.IOException
public void fromFileBis(java.lang.String name)
throws java.io.IOException
name - the name of the file
java.io.IOExceptionpublic int size()
public int enum(int p)
num. All leaves get the num = -1.
p - the name of the root
p + the number of internal nodes of the trie.public IDFA toIDFAbis(Alphabet alph)
public void copybis(IDFA a)
public DFA toDFAbis(Alphabet alph)
public void copybis(DFA a)
public IDFA toIDFA(Alphabet alph)
public int copy(int p,
IDFA a)
public DFA toDFA(Alphabet alph)
public int copy(int p,
DFA a)
public Dawg toDawg()
public java.lang.String toString()
public static void main(java.lang.String[] args)
throws java.lang.Exception
java.lang.Exception
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||