edu.illinois.cs.cogcomp.lbj.coref.ir.examples
Class CExample

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.ir.examples.Example
      extended by edu.illinois.cs.cogcomp.lbj.coref.ir.examples.CExample
All Implemented Interfaces:
java.io.Serializable

public class CExample
extends Example
implements java.io.Serializable

A coreference example (CExample) is a pair of referrers, where each referrer is either an entity mention or a set of entity mentions, and the document containing the mentions. A CExample is the input to classifiers that determine coreference.

Author:
Eric Bengtson
See Also:
Serialized Form

Field Summary
private  java.util.Set<Mention> m_c1
           
private  java.util.Set<Mention> m_c2
           
 Doc m_doc
           
private  Mention m_m1
           
private  Mention m_m2
           
private  boolean m_positive
           
private static long serialVersionUID
           
 
Constructor Summary
CExample(Doc doc, Mention m1, Mention m2)
          Construct a coreference example referring to mentions m1 and m2 in the context of doc.
CExample(Doc doc, java.util.Set<Mention> c1, Mention m2)
          Construct a coreference example referring to a cluster of mentions c1 and a mention m2 in the context of a document doc.
CExample(Doc doc, java.util.Set<Mention> c1, Mention m2, boolean positiveExample)
          Construct a coreference example referring to a set of mentions c1 and a mention m2 in the context of a document doc.
CExample(Doc doc, java.util.Set<Mention> c1, java.util.Set<Mention> c2)
          Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc.
CExample(Doc doc, java.util.Set<Mention> c1, java.util.Set<Mention> c2, boolean positiveExample)
          Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc.
CExample(Doc doc, java.util.Set<Mention> c1, java.util.Set<Mention> c2, Mention m1, Mention m2)
          Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc.
CExample(Doc doc, java.util.Set<Mention> c1, java.util.Set<Mention> c2, Mention m1, Mention m2, boolean positiveExample)
          Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc.
 
Method Summary
 boolean areCoreferent()
          Assumes true knowledge has been given, either using a constructor, the settings of the EntityID labels, or using the setPositive() method.
 java.util.Set<Mention> getC1()
          Gets the first set of mentions, if available.
 java.util.Set<Mention> getC2()
          Gets the second set of mentions, if available.
 Doc getDoc()
          Gets the document that provides context for the mentions in the example.
 Mention getM(int n)
          Gets the specified mention.
 Mention getM1()
          Gets the first mention, if available.
 Mention getM2()
          Gets the second mention, if available.
 boolean isPositive()
          Determines whether this is a positive example.
 void setPositive(boolean isPos)
          This method may be used along with a constructor that does not take the coreference status as input to override the automatically determined result of the areCoreferent() method.
 java.lang.String toString()
          Computes a string representation of this example.
 
Methods inherited from class edu.illinois.cs.cogcomp.lbj.coref.ir.examples.Example
getLabel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

m_doc

public Doc m_doc

m_m1

private Mention m_m1

m_m2

private Mention m_m2

m_c1

private java.util.Set<Mention> m_c1

m_c2

private java.util.Set<Mention> m_c2

m_positive

private boolean m_positive
Constructor Detail

CExample

public CExample(Doc doc,
                Mention m1,
                Mention m2)
Construct a coreference example referring to mentions m1 and m2 in the context of doc. If mentions lack (true) EntityID, use setPositive() or do not rely on areCoreferent().

Parameters:
doc - The document containing the mentions.
m1 - The first mention, which generally occurs before m2 in the document.
m2 - The second mention, which is the anaphor, and generally occurs after m1.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                Mention m2)
Construct a coreference example referring to a cluster of mentions c1 and a mention m2 in the context of a document doc. Used to determine whether m2 refers to the entity represented by the mentions in c1. Cluster c1 and m2 are defined to be coreferential with only if all mentions in c1 have the same entity ID as m2. In case c1 is empty, c1 and m2 will be considered coreferent. If mentions lack (true) EntityID, use setPositive() or do not rely on areCoreferent().

Parameters:
doc - The document containing the mentions.
c1 - The set of mentions thought to refer to an entity (copied defensively). c1 must be non-empty
m2 - The second mention, which is the anaphor.
Throws:
java.lang.IllegalArgumentException - if c1 is empty.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                Mention m2,
                boolean positiveExample)
Construct a coreference example referring to a set of mentions c1 and a mention m2 in the context of a document doc. Used to determine whether m2 refers to the entity represented by the mentions in c1.

Parameters:
doc - The document containing the mentions.
c1 - A set of mentions (copied defensively).
m2 - The second mention, which is the anaphor.
positiveExample - Specify whether this example should be considered a positive one.
Throws:
java.lang.IllegalArgumentException - if c1 is empty.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                java.util.Set<Mention> c2)
Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc. Used to determine whether mentions in c2 refer to the same entity as the the mentions in c1. (The exact criteria for coreference are left undefined -- whether this example is coreferential is specified by setPositive().)

Parameters:
doc - The document containing the mentions.
c1 - A set of mentions (copied defensively).
c2 - A second set of mentions (copied defensively).
Throws:
java.lang.IllegalArgumentException - if c1 or c2 is empty.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                java.util.Set<Mention> c2,
                boolean positiveExample)
Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc. Used to determine whether mentions in c2 refer to the same entity as the the mentions in c1. (The exact criteria for coreference are left undefined -- whether this example is coreferential is specified by positiveExample.)

Parameters:
doc - The document containing the mentions.
c1 - A set of mentions (copied defensively).
c2 - A second set of mentions (copied defensively).
positiveExample - Specify whether this example should be considered a positive one.
Throws:
java.lang.IllegalArgumentException - if c1 or c2 is empty.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                java.util.Set<Mention> c2,
                Mention m1,
                Mention m2)
Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc. Used to determine whether mentions in c2 refer to the same entity as the the mentions in c1. (The exact criteria for coreference are left undefined -- whether this example is coreferential is specified by setPositive().)

Parameters:
doc - The document containing the mentions.
c1 - A set of mentions (copied defensively).
c2 - A second set of mentions (copied defensively).
m1 - The canonical mention of c1.
m2 - The canonical mention of c2.
Throws:
java.lang.IllegalArgumentException - if c1 or c2 is empty.

CExample

public CExample(Doc doc,
                java.util.Set<Mention> c1,
                java.util.Set<Mention> c2,
                Mention m1,
                Mention m2,
                boolean positiveExample)
Construct a coreference example referring to a set of mentions c1 and a set of mentions c2 in the context of a document doc. Used to determine whether mentions in c2 refer to the same entity as the the mentions in c1. (The exact criteria for coreference are left undefined -- whether this example is coreferential is specified by positiveExample.)

Parameters:
doc - The document containing the mentions.
c1 - A set of mentions.
c2 - A second set of mentions.
m1 - The canonical mention of c1.
m2 - The canonical mention of c2.
positiveExample - Specify whether this example should be considered a positive one.
Throws:
java.lang.IllegalArgumentException - if c1 or c2 is empty.
Method Detail

areCoreferent

public boolean areCoreferent()
Assumes true knowledge has been given, either using a constructor, the settings of the EntityID labels, or using the setPositive() method.

Returns:
For the mention pair case, returns true if the pair are truly coreferential, and false otherwise; For the cluster case, should return true if all pairs in the cross product of the clusters are truly coreferential, false if such pairs are not coreferential, and the result is user-defined in any other case (Note: The default definition of areCoreferent() is subject to change). (See the comment on the constructors or the setPositive() method.)

getM1

public Mention getM1()
Gets the first mention, if available.

Returns:
The first mention (which may be an arbitrary mention from the Set c1 if specified, or null if no first mention is available.

getM2

public Mention getM2()
Gets the second mention, if available.

Returns:
The second mention (which may be an arbitrary mention from the Set c2 if specified, or null if no second mention is available.

getM

public Mention getM(int n)
Gets the specified mention.

Parameters:
n - if 1, return m1, if 2, return m2.
Throws:
java.lang.IllegalArgumentException - if n is not 1 or 2.

getC1

public java.util.Set<Mention> getC1()
Gets the first set of mentions, if available.

Returns:
An unmodifiable view of the first set of mentions, or a set containing m1 if no cluster has been specified.

getC2

public java.util.Set<Mention> getC2()
Gets the second set of mentions, if available.

Returns:
An unmodifiable view of the second set of mentions. or a set containing m2 if no cluster has been specified.

getDoc

public Doc getDoc()
Gets the document that provides context for the mentions in the example.

Returns:
the Doc containing the mentions.

setPositive

public void setPositive(boolean isPos)
This method may be used along with a constructor that does not take the coreference status as input to override the automatically determined result of the areCoreferent() method. In the cluster case, it is recommended that isPos be set to true if all pairs in the cross-product are coreferential, and false if all such pairs are non-coreferential; in case some pairs are coreferential, the user may choose an intended interpretation. (Note: The default definition of areCoreferent() is subject to change).

Parameters:
isPos - Specifies whether this example should be considered positive.

isPositive

public boolean isPositive()
Determines whether this is a positive example.

Returns:
whether this is a positive example, according to the entity IDs, constructor, or setPositive method.

toString

public java.lang.String toString()
Computes a string representation of this example. Presently, this string is of the form &gt;m1;<br>m2&lt; or if c1 or c2 are present, m1 or m2 is replaced with a comma separated list of mentions.

Overrides:
toString in class java.lang.Object