com.aliasi.lm
Interface TrieWriter

All Known Implementing Classes:
BitTrieWriter

public interface TrieWriter

The TrieWriter interface provides a means to write an arbitrary trie structure with positive node counts.

A trie is encoded depth-first according to the following recursive definition. First, the the count of the tree (count) is encoded. Then, for each daughter K, 1 <= K <= N, in increasing symbol order, the daughter symbol (dtrSymK) is encoded followed by the encoding of the daughter tree (dtrTreeK). Finally, after the last daughter tree is encoded, the number -1 is encoded.

 encode(tree) =
   count
   dtrSym1
   encode(dtrTree1)
   ...
   dtrSymN
   encode(dtrTreeN)
   -1
 

This results in a unique depth-first encoding of an entire tree as a sequence of long values.

Since:
LingPipe2.3
Version:
2.3
Author:
Bob Carpenter

Method Summary
 void writeCount(long count)
          Writes the specified count for the next sub-trie.
 void writeSymbol(long symbol)
          Writes the specified symbol for the next daughter.
 

Method Detail

writeCount

void writeCount(long count)
                throws IOException
Writes the specified count for the next sub-trie.

Parameters:
count - Count to write.
Throws:
IOException - If there is an underlying I/O error.
IllegalStateException - If it is not legal to write a count into the current sequence.

writeSymbol

void writeSymbol(long symbol)
                 throws IOException
Writes the specified symbol for the next daughter.

The symbol -1 must be written following the last daughter of a tree.

Parameters:
symbol - Symbol to write.
Throws:
IOException - If there is an underlying I/O error.
IllegalStateException - If it is not legal to write a symbol into the current sequence.