|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.illinois.cs.cogcomp.lbj.coref.ir.solutions.ChainSolution<T>
T
- The type of element in the partition.public class ChainSolution<T>
Represents a partition(a set of non-overlapping subsets called chains) and edges linking some items in the partition, along with edge labels. Provides functionality for linking chains and recording information about the links. In all cases defensive copying is done to inputs and unmodifiable views are returned. However, the underlying elements (of type T) are never copied. NOTE WELL: Depends on T objects being hashable (only an issue if two objects might be identical but independently created.)
Field Summary | |
---|---|
private java.util.Map<T,T> |
m_antecedents
|
private java.util.List<java.util.Set<T>> |
m_chains
|
private java.util.Map<Pair<T,T>,java.util.List<java.lang.String>> |
m_edgeLabels
|
private java.util.List<Pair<T,T>> |
m_edges
|
private java.util.Map<T,java.util.Set<T>> |
m_mapToChains
|
private java.util.Map<T,java.util.Set<T>> |
m_referrers
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
ChainSolution()
Constructs an empty solution. |
|
ChainSolution(ChainSolution<T> otherSol)
Copy constructor. |
|
ChainSolution(java.util.Collection<java.util.Collection<T>> chains)
Constructs a ChainSolution from a collection of chains (collections). |
Method Summary | |
---|---|
void |
add(ChainSolution<T> otherSol)
Adds all the chains from otherSol to this,
including the edge labels. |
void |
addChain(java.util.Collection<T> chain)
Adds a chain. |
boolean |
areTogether(T a,
T b)
Determines whether two elements are in the same chain (subset). |
boolean |
contains(T item)
Determines whether the partition contains the specified item in any of its subsets. |
boolean |
equals(java.lang.Object o)
Two ChainSolutions are equal if their subsets are equal. |
java.util.Set<T> |
getAllMembers()
Gets an unmodifiable view all elements of the partition. |
java.util.Set<T> |
getChainContaining(java.util.Set<T> subset)
Gets the chain that is a superset of the specified set. |
java.util.Set<T> |
getChainOf(T item)
Gets the chain containing the specified item, or null if the item is not present. |
java.util.List<java.util.Set<T>> |
getChains()
Gets an unmodifiable view of the chains of this partition. |
java.util.Set<T> |
getContainerFor(T item)
Gets the chain containing the specified item, or null if the item is not present. |
java.util.List<java.lang.String> |
getEdgeLabelsFor(Pair<T,T> p)
Gets the edges for a pair of objects. |
java.util.List<Pair<T,T>> |
getEdges()
Gets the edges. |
java.util.List<java.util.Set<T>> |
getSubsets()
Gets an unmodifiable view of the subsets of this partition. |
int |
hashCode()
Generate hash code based on the collection of chains. |
void |
link(java.util.Set<T> chainA,
T b,
java.util.List<java.lang.String> labels)
Links an object to a chain, applying labels. |
void |
link(java.util.Set<T> chainA,
T b,
java.lang.String label)
Links an object to a chain, applying a label. |
void |
linkChains(java.util.Set<T> chainA,
java.util.Set<T> chainB)
Links the chains. |
void |
linkChains(java.util.Set<T> chainA,
java.util.Set<T> chainB,
java.util.List<java.lang.String> labels)
Links the chains, applying labels. |
void |
linkChains(java.util.Set<T> chainA,
java.util.Set<T> chainB,
java.lang.String label)
Links the chains, applying label. |
private void |
mergeChains(java.util.Set<T> c1,
java.util.Set<T> c2,
int n1,
int n2)
Utility function for merging chains. |
void |
recordDistinctness(T o1,
T o2)
Records the existence of two objects. |
void |
recordEquivalence(java.util.Set<T> chainA,
java.util.Set<T> chainB)
Records equivalence by recording the equivalence of all pairs of items in the chains. |
void |
recordEquivalence(T o1,
T o2)
Records the equivalence of two objects, adding them to the same subset of the partition if not yet present, or linking the subsets containing them if present. |
void |
recordEquivalence(T o1,
T o2,
java.util.List<java.lang.String> labels)
Records the equivalence of two objects, adding them to the same subset of the partition if not yet present, or linking the subsets containing them if present. |
void |
recordEquivalence(T o1,
T o2,
java.lang.String label)
Records the equivalence of two objects, adding them to the same subset of the partition if not yet present, or linking the subsets containing them if present. |
void |
recordExistence(T c)
Ensures that c is contained in some chain;
if it is not yet, it is added to its own new chain. |
protected void |
setup()
Initialize the member collections to empty. |
java.lang.String |
toDiffString(ChainSolution<T> other,
java.lang.String fAbsentMark,
java.lang.String fPresentMark)
Gets a string showing the difference between this and another ChainSolution. |
java.lang.String |
toString()
Represents this partition as a string. |
protected void |
updateMapToChains(T obj,
java.util.Set<T> chain)
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
private java.util.List<java.util.Set<T>> m_chains
private java.util.Map<T,java.util.Set<T>> m_mapToChains
private java.util.List<Pair<T,T>> m_edges
private java.util.Map<T,T> m_antecedents
private java.util.Map<T,java.util.Set<T>> m_referrers
private java.util.Map<Pair<T,T>,java.util.List<java.lang.String>> m_edgeLabels
Constructor Detail |
---|
public ChainSolution()
public ChainSolution(ChainSolution<T> otherSol)
otherSol
.
public ChainSolution(java.util.Collection<java.util.Collection<T>> chains)
chains
will not affect this).
chains
- A collection of chains.Method Detail |
---|
protected void setup()
public void add(ChainSolution<T> otherSol)
otherSol
to this,
including the edge labels.
Edges are copied defensively.
Any existing edges in this
that are also in otherSol
will be overwritten in this
.
otherSol
- Another solution.public void addChain(java.util.Collection<T> chain)
chain
- The chain to add.public boolean areTogether(T a, T b)
this
partition.
a
- An element.b
- Another element.
public boolean contains(T item)
item
- An item.
public java.util.Set<T> getAllMembers()
public java.util.List<java.util.Set<T>> getChains()
public java.util.List<java.util.Set<T>> getSubsets()
public java.util.Set<T> getChainOf(T item)
public java.util.Set<T> getContainerFor(T item)
public java.util.Set<T> getChainContaining(java.util.Set<T> subset)
subset
,
or null if no chain is found.public java.util.List<Pair<T,T>> getEdges()
Pair
s.public java.util.List<java.lang.String> getEdgeLabelsFor(Pair<T,T> p)
protected void updateMapToChains(T obj, java.util.Set<T> chain)
public void recordEquivalence(T o1, T o2, java.lang.String label)
o1
- The first object.o2
- The second object.label
- The label to append to the edge between o1
and o2
.public void recordEquivalence(T o1, T o2, java.util.List<java.lang.String> labels)
o1
- The first object.o2
- The second object.labels
- The labels to apply to the edge between o1
and o2
. Any existing labels are replaced.public void recordEquivalence(java.util.Set<T> chainA, java.util.Set<T> chainB)
chainA
or chainB
will not affect this partition.
chainA
- One set of objects.chainB
- Another set of objects.public void linkChains(java.util.Set<T> chainA, java.util.Set<T> chainB)
chainA
or chainB
will not affect this partition.
chainA
- A chain.chainB
- Another chain.public void linkChains(java.util.Set<T> chainA, java.util.Set<T> chainB, java.lang.String label)
chainA
or chainB
will not affect this partition.
Label is copied defensively and overwrites any existing
labels between the linked mentions.
chainA
- A chain.chainB
- Another chain.public void linkChains(java.util.Set<T> chainA, java.util.Set<T> chainB, java.util.List<java.lang.String> labels)
chainA
or chainB
will not affect this partition.
Labels are copied defensively and overwrite any existing
labels between the linked mentions.
chainA
- A chain.chainB
- Another chain.labels
- Labels.public void link(java.util.Set<T> chainA, T b, java.lang.String label)
chainA
and b
.
chainA
must already exist in full in the partition.
Subsequent modifications of chainA
will not affect this partition.
Label is copied defensively and overwrites any existing
labels between the linked mentions.
chainA
- A chain.b
- An object.label
- A label.public void link(java.util.Set<T> chainA, T b, java.util.List<java.lang.String> labels)
chainA
and b
.
chainA
must already exist in full in the partition.
Subsequent modifications of chainA
will not affect this partition.
Labels are copied defensively and overwrite any existing
labels between the linked mentions.
chainA
- A chain.b
- An object.labels
- The labels.private void mergeChains(java.util.Set<T> c1, java.util.Set<T> c2, int n1, int n2)
c1
- One chain.c2
- Another chain.n1
- The first chain's index in m_chains.n2
- The second chain's index in m_chains.public void recordEquivalence(T o1, T o2)
o1
- An object.o2
- Another object.public void recordDistinctness(T o1, T o2)
o1
- An object.o2
- Another object.public void recordExistence(T c)
c
is contained in some chain;
if it is not yet, it is added to its own new chain.
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDiffString(ChainSolution<T> other, java.lang.String fAbsentMark, java.lang.String fPresentMark)
other
- Another ChainSolution, typically a reference key.fAbsentMark
- denotes things in other
,
but not found in this
.fPresentMark
- denotes things in this
but missing in other
.
this
,
indicating where it differs from other
.public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- Another object.
public int hashCode()
hashCode
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |