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 Object
implements ArpaLmReaderCallback<V>
Reader callback which adds n-grams to an NgramMap
- Author:
- adampauls
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidCalled for each n-gramvoidcleanup()Called once all reading is done.long[]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(List<Long> numNGrams) Called initially with a list of how many n-grams will appear for each order.
-
Constructor Details
-
FirstPassCallback
public FirstPassCallback(boolean reverse)
-
-
Method Details
-
call
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>>- Parameters:
order-
-
cleanup
public void cleanup()Description copied from interface:LmReaderCallbackCalled once all reading is done.- Specified by:
cleanupin interfaceLmReaderCallback<V extends LongRepresentable<V>>
-
getValueCounter
-
initWithLengths
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
-
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>>- Parameters:
order-
-