Package edu.berkeley.nlp.lm.io
Class NgramMapAddingCallback<V>
- java.lang.Object
-
- edu.berkeley.nlp.lm.io.NgramMapAddingCallback<V>
-
- Type Parameters:
V- Value type
- All Implemented Interfaces:
ArpaLmReaderCallback<V>,LmReaderCallback<V>,NgramOrderedLmReaderCallback<V>
public final class NgramMapAddingCallback<V> extends java.lang.Object implements ArpaLmReaderCallback<V>
Reader callback which adds n-grams to an NgramMap- Author:
- adampauls
-
-
Constructor Summary
Constructors Constructor Description NgramMapAddingCallback(NgramMap<V> map, java.util.List<int[]> failures)
-
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.java.util.List<int[]>getFailures()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>- 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>
-
cleanup
public void cleanup()
Description copied from interface:LmReaderCallbackCalled once all reading is done.- Specified by:
cleanupin interfaceLmReaderCallback<V>
-
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>- Parameters:
numNGrams- maps n-gram orders to number of n-grams (i.e. numNGrams.get(0) is the number of unigrams)
-
getFailures
public java.util.List<int[]> getFailures()
-
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>
-
-