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 void
call(int[] ngram, int startPos, int endPos, V v, java.lang.String words)
Called for each n-gramvoid
cleanup()
Called once all reading is done.java.util.List<int[]>
getFailures()
void
handleNgramOrderFinished(int order)
Called when all n-grams of a given order are finishedvoid
handleNgramOrderStarted(int order)
Called when n-grams of a given order are startedvoid
initWithLengths(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:LmReaderCallback
Called for each n-gram- Specified by:
call
in 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:NgramOrderedLmReaderCallback
Called when all n-grams of a given order are finished- Specified by:
handleNgramOrderFinished
in interfaceNgramOrderedLmReaderCallback<V>
-
cleanup
public void cleanup()
Description copied from interface:LmReaderCallback
Called once all reading is done.- Specified by:
cleanup
in interfaceLmReaderCallback<V>
-
initWithLengths
public void initWithLengths(java.util.List<java.lang.Long> numNGrams)
Description copied from interface:ArpaLmReaderCallback
Called initially with a list of how many n-grams will appear for each order.- Specified by:
initWithLengths
in 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:NgramOrderedLmReaderCallback
Called when n-grams of a given order are started- Specified by:
handleNgramOrderStarted
in interfaceNgramOrderedLmReaderCallback<V>
-
-