edu.stanford.nlp.stats
Class TwoDimensionalCounter<K1,K2>
java.lang.Object
edu.stanford.nlp.stats.TwoDimensionalCounter<K1,K2>
- All Implemented Interfaces:
- Serializable
public class TwoDimensionalCounter<K1,K2>
- extends Object
- implements Serializable
A class representing a mapping between pairs of typed objects and double values.
- Author:
- Teg Grenager
- See Also:
- Serialized Form
Method Summary |
void |
addAll(TwoDimensionalCounter<K1,K2> c)
|
boolean |
containsKey(K1 o1,
K2 o2)
|
Set<Map.Entry<K1,Counter<K2>>> |
entrySet()
|
Set<K1> |
firstKeySet()
|
Counter<Pair<K1,K2>> |
flatten()
|
double |
getCount(K1 o1,
K2 o2)
|
Counter<K2> |
getCounter(K1 o)
|
MapFactory |
getMapFactory()
|
void |
incrementCount(K1 o1,
K2 o2)
|
void |
incrementCount(K1 o1,
K2 o2,
double count)
|
boolean |
isEmpty()
|
static void |
main(String[] args)
|
static TwoDimensionalCounter |
reverseIndexOrder(TwoDimensionalCounter cc)
Produces a new ConditionalCounter. |
Set<K2> |
secondKeySet()
|
void |
setCount(K1 o1,
K2 o2,
double count)
|
Counter<K2> |
setCounter(K1 o,
Counter<K2> c)
|
int |
size()
|
void |
subtractAll(TwoDimensionalCounter<K1,K2> c,
boolean removeKeys)
|
String |
toCSVString(NumberFormat nf)
|
String |
toDatFileString()
|
double[][] |
toMatrix(List<K1> firstKeys,
List<K2> secondKeys)
Given an ordering of the first (row) and second (column) keys, will produce a double matrix. |
String |
toMatrixString(int cellSize)
|
String |
toString()
|
double |
totalCount()
Takes linear time. |
double |
totalCount(K1 k1)
|
serialVersionUID
public static final long serialVersionUID
- See Also:
- Constant Field Values
TwoDimensionalCounter
public TwoDimensionalCounter()
TwoDimensionalCounter
public TwoDimensionalCounter(MapFactory factory)
getCounter
public Counter<K2> getCounter(K1 o)
- Parameters:
o
-
- Returns:
- the inner Counter associated with key o
entrySet
public Set<Map.Entry<K1,Counter<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)
- Parameters:
o1
- o2
-
incrementCount
public void incrementCount(K1 o1,
K2 o2,
double count)
- Parameters:
o1
- o2
- count
-
setCount
public void setCount(K1 o1,
K2 o2,
double count)
- Parameters:
o1
- o2
- count
-
getCount
public double getCount(K1 o1,
K2 o2)
- Parameters:
o1
- o2
-
- Returns:
totalCount
public double totalCount()
- Takes linear time.
- Returns:
totalCount
public double totalCount(K1 k1)
- Returns:
firstKeySet
public Set<K1> firstKeySet()
setCounter
public Counter<K2> setCounter(K1 o,
Counter<K2> c)
reverseIndexOrder
public static TwoDimensionalCounter reverseIndexOrder(TwoDimensionalCounter cc)
- Produces a new ConditionalCounter.
- Parameters:
cc
-
- Returns:
- a new ConditionalCounter, where order of indices is reversed
toString
public String toString()
- Overrides:
toString
in class Object
toDatFileString
public String toDatFileString()
toMatrixString
public String toMatrixString(int cellSize)
toMatrix
public double[][] toMatrix(List<K1> firstKeys,
List<K2> secondKeys)
- Given an ordering of the first (row) and second (column) keys, will produce a double matrix.
- Parameters:
firstKeys
- secondKeys
-
- Returns:
toCSVString
public String toCSVString(NumberFormat nf)
secondKeySet
public Set<K2> secondKeySet()
isEmpty
public boolean isEmpty()
flatten
public Counter<Pair<K1,K2>> flatten()
addAll
public void addAll(TwoDimensionalCounter<K1,K2> c)
subtractAll
public void subtractAll(TwoDimensionalCounter<K1,K2> c,
boolean removeKeys)
getMapFactory
public MapFactory getMapFactory()
main
public static void main(String[] args)
Stanford NLP Group