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

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

public class NgramMapWrapper<W,V>
extends AbstractMap<List<W>,V>

Wraps an NgramMap as a Java Map, with ngrams of all orders mixed together. This collection is read-only. It is also uses a lot inefficient boxing and unboxing.

Author:
adampauls

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
NgramMapWrapper(NgramMap<V> map, WordIndexer<W> wordIndexer)
           
NgramMapWrapper(NgramMap<V> map, WordIndexer<W> wordIndexer, int maxOrder)
           
 
Method Summary
 boolean containsKey(Object key)
           
 Set<Map.Entry<List<W>,V>> entrySet()
           
 V get(Object arg0)
           
 Map<List<W>,V> getMapForOrder(int ngramOrder)
           
 NgramMap<V> getNgramMap()
           
 WordIndexer<W> getWordIndexer()
           
 long longSize()
           
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NgramMapWrapper

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

NgramMapWrapper

public NgramMapWrapper(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

get

public V get(Object arg0)
Specified by:
get in interface Map<List<W>,V>
Overrides:
get in class AbstractMap<List<W>,V>

containsKey

public boolean containsKey(Object key)
Specified by:
containsKey in interface Map<List<W>,V>
Overrides:
containsKey in class AbstractMap<List<W>,V>

entrySet

public Set<Map.Entry<List<W>,V>> entrySet()
Specified by:
entrySet in interface Map<List<W>,V>
Specified by:
entrySet in class AbstractMap<List<W>,V>

getMapForOrder

public Map<List<W>,V> getMapForOrder(int ngramOrder)
Parameters:
ngramOrder - 0-based (0 means unigrams)
Returns:

longSize

public long longSize()
Returns:

getWordIndexer

public WordIndexer<W> getWordIndexer()

getNgramMap

public NgramMap<V> getNgramMap()