Class StaticNGramTrieNode


  • public class StaticNGramTrieNode
    extends AbstractNGramTrieNode<StaticNGramTrieNode>
    Represent a static ngram trie node : when node are used only to retrieve information and compute probabilities, but children are never updated.
    This node is particular because children node are loaded on demand from a FileChannel.
    This node is produced in a read only version : to create this node, DynamicNGramTrieNode and TrainingNGramDictionary should be used.
    • Constructor Detail

      • StaticNGramTrieNode

        public StaticNGramTrieNode()
    • Method Detail

      • getNodeFor

        public StaticNGramTrieNode getNodeFor​(java.nio.channels.FileChannel fileChannel,
                                              int[] prefix,
                                              int index)
                                       throws java.io.IOException
        Will try to retrieve a node for a given prefix.
        Load needed node on demand while browsing the trie.
        Children of the returned node are not loaded yet.
        Parameters:
        fileChannel - the file channel containing the trie structure.
        prefix - ngram prefix
        index - index in prefix (0 = full prefix)
        Returns:
        the node found for the given prefix (or null if the trie doesn't contains any node for the given prefix)
        Throws:
        java.io.IOException - if children can't be read for a node
      • checkChildrenLoading

        public boolean checkChildrenLoading​(java.nio.channels.FileChannel fileChannel)
                                     throws java.io.IOException
        Check that children for this node are loaded.
        If not, try to load children from the given fileChannel.
        Parameters:
        fileChannel - file channel containing the trie structure.
        Returns:
        true if there is children and children are loaded.
        Throws:
        java.io.IOException - if there is children, but they can't be loaded
      • readNodeInformation

        public int readNodeInformation​(java.nio.ByteBuffer buffWrite)
        Read the node information contained into the given buffer to this node (without any check).
        Parameters:
        buffWrite - the buffer containing node information.
        Returns:
        this node word id (read from buffer)