edu.berkeley.nlp.lm.map
Class NgramIterableWrapper<W,V>

java.lang.Object
  extended by edu.berkeley.nlp.lm.map.NgramIterableWrapper<W,V>
Type Parameters:
V -
W -
All Implemented Interfaces:
Iterable<Map.Entry<List<W>,V>>

public class NgramIterableWrapper<W,V>
extends Object
implements Iterable<Map.Entry<List<W>,V>>

Wraps an NgramMap as an Iterable, so it is easy to iterate over the n-grams and associated values. Using this interface is a little inefficient due to the boxing and temporary object allocation necessary to conform to Java's interfaces.

Author:
adampauls

Constructor Summary
NgramIterableWrapper(NgramMap<V> map, WordIndexer<W> wordIndexer)
           
NgramIterableWrapper(NgramMap<V> map, WordIndexer<W> wordIndexer, int maxOrder)
           
 
Method Summary
 Iterator<Map.Entry<List<W>,V>> iterator()
           
 long size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NgramIterableWrapper

public NgramIterableWrapper(NgramMap<V> map,
                            WordIndexer<W> wordIndexer)

NgramIterableWrapper

public NgramIterableWrapper(NgramMap<V> map,
                            WordIndexer<W> wordIndexer,
                            int maxOrder)
Parameters:
map -
wordIndexer -
maxOrder - this is 1-based (i.e. 1 means keep unigrams but not bigrams)
Method Detail

iterator

public Iterator<Map.Entry<List<W>,V>> iterator()
Specified by:
iterator in interface Iterable<Map.Entry<List<W>,V>>

size

public long size()