com.aliasi.lm
Class BitTrieWriter

java.lang.Object
  extended by com.aliasi.lm.BitTrieWriter
All Implemented Interfaces:
TrieWriter

public class BitTrieWriter
extends Object
implements TrieWriter

A BitTrieWriter provides a trie writer that wraps a bit-level output.

The reader for the output of a bit trie writer is BitTrieReader.

Counts of trie nodes and differences between successive symbols on transitions are delta coded for compression (see BitOutput.writeDelta(long)).

The method copy(TrieReader,TrieWriter) is available to copy the contents of a reader to a writer.

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

Constructor Summary
BitTrieWriter(BitOutput bitOutput)
          Construct a bit trie writer from the specified bit output with the specified maximum n-gram.
 
Method Summary
static void copy(TrieReader reader, TrieWriter writer)
          Copies the content of the specified trie reader to the specified trie writer.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitTrieWriter

public BitTrieWriter(BitOutput bitOutput)
Construct a bit trie writer from the specified bit output with the specified maximum n-gram.

Parameters:
bitOutput - Underlying bit output.
Method Detail

writeCount

public void writeCount(long count)
                throws IOException
Description copied from interface: TrieWriter
Writes the specified count for the next sub-trie.

Specified by:
writeCount in interface TrieWriter
Parameters:
count - Count to write.
Throws:
IOException - If there is an underlying I/O error.

writeSymbol

public void writeSymbol(long symbol)
                 throws IOException
Description copied from interface: TrieWriter
Writes the specified symbol for the next daughter.

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

Specified by:
writeSymbol in interface TrieWriter
Parameters:
symbol - Symbol to write.
Throws:
IOException - If there is an underlying I/O error.

copy

public static void copy(TrieReader reader,
                        TrieWriter writer)
                 throws IOException
Copies the content of the specified trie reader to the specified trie writer.

Parameters:
reader - Reader from which to read.
writer - Writer to which to write.
Throws:
IOException