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 Object implements ArpaLmReaderCallback<V>
Reader callback which adds n-grams to an NgramMap
Author:
adampauls
  • Constructor Details

    • NgramMapAddingCallback

      public NgramMapAddingCallback(NgramMap<V> map, List<int[]> failures)
  • Method Details

    • call

      public void call(int[] ngram, int startPos, int endPos, V v, String words)
      Description copied from interface: LmReaderCallback
      Called for each n-gram
      Specified by:
      call in interface LmReaderCallback<V>
      Parameters:
      ngram - The integer representation of the words as given by the provided WordIndexer
      v - The value of the n-gram
      words - 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 interface NgramOrderedLmReaderCallback<V>
    • cleanup

      public void cleanup()
      Description copied from interface: LmReaderCallback
      Called once all reading is done.
      Specified by:
      cleanup in interface LmReaderCallback<V>
    • initWithLengths

      public void initWithLengths(List<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 interface ArpaLmReaderCallback<V>
      Parameters:
      numNGrams - maps n-gram orders to number of n-grams (i.e. numNGrams.get(0) is the number of unigrams)
    • getFailures

      public 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 interface NgramOrderedLmReaderCallback<V>