Implementation based on "Incremental Construction of Minimal Acyclic Finite-State Automata" by Jan Daciuk, Stoyan Mihov, Bruce W. Watson and Richard E. Watson.
npm install dtrie
To run the unit tests:
To run the performance/stress tests:
npm run-script stress
Basic dictionary usage:
var dtrie = ;var trie = dtrie;assert;assert;
Construct a dictionary from a file.
Construct a dictionary from a list of words.
Construct a new node.
Node's id, unique to each node.
Return true if this node has a child for the given transition.
Return the node child.
Check if this node recognize the given suffix.
Return true if the current node is a terminal node.
This class is a subclass of Node and represent an automaton.
Construct a new automaton.
Populate the automaton from an alphabetically sorted list of lowercase words. This method should only be called once per automaton. Words must contain letters within range [a-z].
Return true if the automaton recognize the given word.
Return the number of nodes in the automaton.
This code is free to use under the terms of the MIT license.