com.aliasi.lm
Class PruneTrieReader

java.lang.Object
  extended by com.aliasi.lm.PruneTrieReader
All Implemented Interfaces:
TrieReader

public class PruneTrieReader
extends Object

A PruneTrieReader filters a contained trie reader by removing all subtrees whose counts fall below a specified minimum.

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

Constructor Summary
PruneTrieReader(TrieReader reader, long minCount)
          Construct a scaling trie reader wrapping the specified reader which deletes all subtrees with counts below the specified minimum.
 
Method Summary
 long readCount()
          Returns the count of the next tree.
 long readSymbol()
          Returns the identifier of the symbol leading from the root of the current tree to the daughter subtree for the symbol, or -1 if there are no more subtrees for the current node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PruneTrieReader

public PruneTrieReader(TrieReader reader,
                       long minCount)
                throws IOException
Construct a scaling trie reader wrapping the specified reader which deletes all subtrees with counts below the specified minimum.

Parameters:
reader - Contained reader.
minCount - Minimum count to retain a subtree.
Throws:
IllegalArgumentException - If the minimum count is negative.
IOException
Method Detail

readCount

public long readCount()
Description copied from interface: TrieReader
Returns the count of the next tree.

Specified by:
readCount in interface TrieReader
Returns:
The count of the next tree.

readSymbol

public long readSymbol()
                throws IOException
Description copied from interface: TrieReader
Returns the identifier of the symbol leading from the root of the current tree to the daughter subtree for the symbol, or -1 if there are no more subtrees for the current node.

Specified by:
readSymbol in interface TrieReader
Returns:
The symbol leading to the next subtree.
Throws:
IOException - If there is an underlying I/O error.