Package edu.berkeley.nlp.lm.io
Class FirstPassCallback<V extends LongRepresentable<V>>
- java.lang.Object
-
- edu.berkeley.nlp.lm.io.FirstPassCallback<V>
-
- Type Parameters:
V- Value type
- All Implemented Interfaces:
ArpaLmReaderCallback<V>,LmReaderCallback<V>,NgramOrderedLmReaderCallback<V>
public final class FirstPassCallback<V extends LongRepresentable<V>> extends java.lang.Object implements ArpaLmReaderCallback<V>
Reader callback which adds n-grams to an NgramMap- Author:
- adampauls
-
-
Constructor Summary
Constructors Constructor Description FirstPassCallback(boolean reverse)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcall(int[] ngram, int startPos, int endPos, V v, java.lang.String words)Called for each n-gramvoidcleanup()Called once all reading is done.long[]getNumNgramsForEachOrder()LongArray[]getNumNgramsForEachWord()LongToIntHashMapgetValueCounter()voidhandleNgramOrderFinished(int order)Called when all n-grams of a given order are finishedvoidhandleNgramOrderStarted(int order)Called when n-grams of a given order are startedvoidinitWithLengths(java.util.List<java.lang.Long> numNGrams)Called initially with a list of how many n-grams will appear for each order.
-
-
-
Method Detail
-
call
public void call(int[] ngram, int startPos, int endPos, V v, java.lang.String words)Description copied from interface:LmReaderCallbackCalled for each n-gram- Specified by:
callin interfaceLmReaderCallback<V extends LongRepresentable<V>>- Parameters:
ngram- The integer representation of the words as given by the provided WordIndexerv- The value of the n-gramwords- The string representation of the n-gram (space separated)
-
handleNgramOrderFinished
public void handleNgramOrderFinished(int order)
Description copied from interface:NgramOrderedLmReaderCallbackCalled when all n-grams of a given order are finished- Specified by:
handleNgramOrderFinishedin interfaceNgramOrderedLmReaderCallback<V extends LongRepresentable<V>>
-
cleanup
public void cleanup()
Description copied from interface:LmReaderCallbackCalled once all reading is done.- Specified by:
cleanupin interfaceLmReaderCallback<V extends LongRepresentable<V>>
-
getValueCounter
public LongToIntHashMap getValueCounter()
-
initWithLengths
public void initWithLengths(java.util.List<java.lang.Long> numNGrams)
Description copied from interface:ArpaLmReaderCallbackCalled initially with a list of how many n-grams will appear for each order.- Specified by:
initWithLengthsin interfaceArpaLmReaderCallback<V extends LongRepresentable<V>>- Parameters:
numNGrams- maps n-gram orders to number of n-grams (i.e. numNGrams.get(0) is the number of unigrams)
-
getNumNgramsForEachWord
public LongArray[] getNumNgramsForEachWord()
-
getNumNgramsForEachOrder
public long[] getNumNgramsForEachOrder()
-
handleNgramOrderStarted
public void handleNgramOrderStarted(int order)
Description copied from interface:NgramOrderedLmReaderCallbackCalled when n-grams of a given order are started- Specified by:
handleNgramOrderStartedin interfaceNgramOrderedLmReaderCallback<V extends LongRepresentable<V>>
-
-