edu.stanford.nlp.stats
Class TwoDimensionalIntCounter<K1,K2>

java.lang.Object
  extended by edu.stanford.nlp.stats.TwoDimensionalIntCounter<K1,K2>
All Implemented Interfaces:
java.io.Serializable

public class TwoDimensionalIntCounter<K1,K2>
extends java.lang.Object
implements java.io.Serializable

A class representing a mapping between pairs of typed objects and int values. (Copied from TwoDimensionalCounter)

Author:
Teg Grenager, Angel Chang
See Also:
Serialized Form

Constructor Summary
TwoDimensionalIntCounter()
           
TwoDimensionalIntCounter(int initialCapacity)
           
TwoDimensionalIntCounter(MapFactory<K1,IntCounter<K2>> outerFactory, MapFactory<K2,MutableInteger> innerFactory)
           
TwoDimensionalIntCounter(MapFactory<K1,IntCounter<K2>> outerFactory, MapFactory<K2,MutableInteger> innerFactory, int initialCapacity)
           
 
Method Summary
 void addAll(K1 key, IntCounter<K2> c)
           
 void addAll(TwoDimensionalIntCounter<K1,K2> c)
           
 void clean()
           
 boolean containsKey(K1 o1, K2 o2)
           
 void decrementCount(K1 o1, K2 o2)
           
 void decrementCount(K1 o1, K2 o2, double count)
           
 void decrementCount(K1 o1, K2 o2, int count)
           
 int defaultReturnValue()
           
 void defaultReturnValue(double rv)
           
 void defaultReturnValue(int rv)
           
 java.util.Set<java.util.Map.Entry<K1,IntCounter<K2>>> entrySet()
           
 boolean equals(java.lang.Object o)
           
 java.util.Set<K1> firstKeySet()
           
 IntCounter<Pair<K1,K2>> flatten()
           
 int getCount(K1 o1, K2 o2)
           
 IntCounter<K2> getCounter(K1 o)
           
 MapFactory<K2,MutableInteger> getInnerMapFactory()
           
 MapFactory<K1,IntCounter<K2>> getOuterMapFactory()
           
 int hashCode()
           
 void incrementCount(K1 o1, K2 o2)
           
 void incrementCount(K1 o1, K2 o2, double count)
           
 void incrementCount(K1 o1, K2 o2, int count)
           
 boolean isEmpty()
           
static void main(java.lang.String[] args)
           
 void remove(K1 key)
           
 int remove(K1 o1, K2 o2)
           
 void removeZeroCounts()
           
static
<K1,K2> TwoDimensionalIntCounter<K2,K1>
reverseIndexOrder(TwoDimensionalIntCounter<K1,K2> cc)
          Produces a new ConditionalCounter.
 java.util.Set<K2> secondKeySet()
           
 void setCount(K1 o1, K2 o2, double count)
           
 void setCount(K1 o1, K2 o2, int count)
           
 IntCounter<K2> setCounter(K1 o, IntCounter<K2> c)
          replace the counter for K1-index o by new counter c
 int size()
           
 void subtractAll(K1 key, IntCounter<K2> c)
           
 void subtractAll(TwoDimensionalIntCounter<K1,K2> c, boolean removeKeys)
           
 java.lang.String toCSVString(java.text.NumberFormat nf)
           
 int[][] toMatrix(java.util.List<K1> firstKeys, java.util.List<K2> secondKeys)
          Given an ordering of the first (row) and second (column) keys, will produce a double matrix.
 java.lang.String toMatrixString(int cellSize)
           
 java.lang.String toString()
          A simple String representation of this TwoDimensionalCounter, which has the String representation of each key pair on a separate line, followed by the count for that pair.
 int totalCount()
          Takes linear time.
 int totalCount(K1 k1)
           
 IntCounter<K1> totalCounts()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TwoDimensionalIntCounter

public TwoDimensionalIntCounter()

TwoDimensionalIntCounter

public TwoDimensionalIntCounter(int initialCapacity)

TwoDimensionalIntCounter

public TwoDimensionalIntCounter(MapFactory<K1,IntCounter<K2>> outerFactory,
                                MapFactory<K2,MutableInteger> innerFactory)

TwoDimensionalIntCounter

public TwoDimensionalIntCounter(MapFactory<K1,IntCounter<K2>> outerFactory,
                                MapFactory<K2,MutableInteger> innerFactory,
                                int initialCapacity)
Method Detail

defaultReturnValue

public void defaultReturnValue(double rv)

defaultReturnValue

public void defaultReturnValue(int rv)

defaultReturnValue

public int defaultReturnValue()

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

getCounter

public IntCounter<K2> getCounter(K1 o)
Returns:
the inner Counter associated with key o

entrySet

public java.util.Set<java.util.Map.Entry<K1,IntCounter<K2>>> entrySet()

size

public int size()
Returns:
total number of entries (key pairs)

containsKey

public boolean containsKey(K1 o1,
                           K2 o2)

incrementCount

public void incrementCount(K1 o1,
                           K2 o2)

incrementCount

public void incrementCount(K1 o1,
                           K2 o2,
                           double count)

incrementCount

public void incrementCount(K1 o1,
                           K2 o2,
                           int count)

decrementCount

public void decrementCount(K1 o1,
                           K2 o2)

decrementCount

public void decrementCount(K1 o1,
                           K2 o2,
                           double count)

decrementCount

public void decrementCount(K1 o1,
                           K2 o2,
                           int count)

setCount

public void setCount(K1 o1,
                     K2 o2,
                     double count)

setCount

public void setCount(K1 o1,
                     K2 o2,
                     int count)

remove

public int remove(K1 o1,
                  K2 o2)

getCount

public int getCount(K1 o1,
                    K2 o2)

totalCount

public int totalCount()
Takes linear time.


totalCount

public int totalCount(K1 k1)

totalCounts

public IntCounter<K1> totalCounts()

firstKeySet

public java.util.Set<K1> firstKeySet()

setCounter

public IntCounter<K2> setCounter(K1 o,
                                 IntCounter<K2> c)
replace the counter for K1-index o by new counter c


reverseIndexOrder

public static <K1,K2> TwoDimensionalIntCounter<K2,K1> reverseIndexOrder(TwoDimensionalIntCounter<K1,K2> cc)
Produces a new ConditionalCounter.

Returns:
a new ConditionalCounter, where order of indices is reversed

toString

public java.lang.String toString()
A simple String representation of this TwoDimensionalCounter, which has the String representation of each key pair on a separate line, followed by the count for that pair. The items are tab separated, so the result is a tab-separated value (TSV) file. Iff none of the keys contain spaces, it will also be possible to treat this as whitespace separated fields.

Overrides:
toString in class java.lang.Object

toMatrixString

public java.lang.String toMatrixString(int cellSize)

toMatrix

public int[][] toMatrix(java.util.List<K1> firstKeys,
                        java.util.List<K2> secondKeys)
Given an ordering of the first (row) and second (column) keys, will produce a double matrix.


toCSVString

public java.lang.String toCSVString(java.text.NumberFormat nf)

secondKeySet

public java.util.Set<K2> secondKeySet()

isEmpty

public boolean isEmpty()

flatten

public IntCounter<Pair<K1,K2>> flatten()

addAll

public void addAll(TwoDimensionalIntCounter<K1,K2> c)

addAll

public void addAll(K1 key,
                   IntCounter<K2> c)

subtractAll

public void subtractAll(K1 key,
                        IntCounter<K2> c)

subtractAll

public void subtractAll(TwoDimensionalIntCounter<K1,K2> c,
                        boolean removeKeys)

removeZeroCounts

public void removeZeroCounts()

remove

public void remove(K1 key)

clean

public void clean()

getOuterMapFactory

public MapFactory<K1,IntCounter<K2>> getOuterMapFactory()

getInnerMapFactory

public MapFactory<K2,MutableInteger> getInnerMapFactory()

main

public static void main(java.lang.String[] args)


Stanford NLP Group