edu.illinois.cs.cogcomp.lbj.coref.ir
Class Mention

java.lang.Object
  extended by edu.illinois.cs.cogcomp.lbj.coref.ir.Mention
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Mention>

public class Mention
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable<Mention>

Represents the ACE mention of some ACE entity in the context of a document. A mention has a head (its head noun phrase) and an extent (the largest noun phrase headed by the head), along with some metadata. Generally, Mentions should be used as singletons, constructed only in the loading of a document, primarily stored in and retrieved from a Doc. Thus, classes should store and manipulate references to an Mention rather than making copies.

Author:
Eric Bengtson
See Also:
Serialized Form

Field Summary
private  java.util.Set<Mention> m_corefMents
           
private  Doc m_doc
           
private  java.lang.String m_entityType
           
private  Chunk m_extent
           
private  Chunk m_head
           
private  java.lang.String m_id
           
 boolean m_isTrueMention
           
private  java.lang.String m_ldcAtr
           
private  java.lang.String m_ldcType
           
private  java.lang.String m_predEntityID
           
 char m_predGender
           
 char m_predNumber
           
 java.lang.String m_predwnEType
           
private  java.lang.String m_role
           
private  java.lang.String m_specificity
           
private  java.lang.String m_subtype
           
private  java.lang.String m_trueEntityID
           
private  java.lang.String m_type
           
private static long serialVersionUID
           
 
Constructor Summary
Mention(Doc d, Chunk headAndExtent)
          A basic constructor that assumes the head and the extent are identical.
Mention(Doc d, java.lang.String id, java.lang.String type, java.lang.String ldcType, java.lang.String ldcAtr, java.lang.String role, Chunk extent, Chunk head, java.lang.String entityID, java.lang.String entityType, java.lang.String subtype, java.lang.String specificity, boolean isTrueMention)
          A complete constructor.
 
Method Summary
 void addCorefMent(Mention m)
          Adds a mention to the set of mentions coreferential with this.
 void addCorefMentsOf(Mention m)
          Adds all the mentions known (or believed) to be coreferential with m to the set of mentions coreferential with this.
 int compareTo(Mention m)
          Compare first by extent, then by head.
 boolean equals(java.lang.Object o)
          equals and hashCode methods inspired by article hosted on Technofundo, called "Equals and Hash Code", by Manish Hatwalne Available as of Feb.
 java.util.Set<Mention> getCorefMents()
          Gets the set of mentions known (or believed) to be coreferential with this mention.
 Doc getDoc()
          Gets the document containing this mention.
 java.lang.String getEntityID()
          Gets the entity ID.
 java.lang.String getEntityType()
          Gets the entity type.
 Chunk getExtent()
          Gets the ACE extent of this mention.
 int getExtentFirstWordNum()
          Gets the position in the document of the first word in the extent.
 int getExtentLastWordNum()
          Gets the position in the document of the last word in the extent.
 Chunk getHead()
          Gets the ACE head of this mention.
 int getHeadFirstWordNum()
          Gets the position in the document of the first word in the head.
 int getHeadLastWordNum()
          Gets the position in the document of the last word in the head.
 java.lang.String getID()
          Gets the mention ID of this mention.
 java.lang.String getLdcAtr()
          Get the LDC Attribute.
 java.lang.String getLdcType()
           
 java.lang.String getPredictedEntityID()
          Gets the predicted entity ID, which may be NONE.
 java.lang.String getPreHeadText()
          Gets the text up to but not including the head.
 java.lang.String getRole()
          Get the role.
 int getSentNum()
          Gets the sentence number of the mention, which is defined as the sentence number of the first word in the head.
 java.lang.String getSpecificity()
          Gets the specificity.
 java.lang.String getSubtype()
          Gets the entity subtype for this mention.
 java.lang.String getText()
          Gets the mention as a string, with vertical bars marking the head unless the extent and head are identical, and with newlines replaced by spaces.
 java.lang.String getThruHeadText()
          Gets the text up to and including the head.
 java.lang.String getTrueEntityID()
          Get the true entity ID.
 java.lang.String getType()
          Gets the mention type.
 int hashCode()
          Gets the hash code, which takes into account the hash codes of the head and extent, but NOT the ID or any other metadata.
private  void readObject(java.io.ObjectInputStream in)
          Serialization read method.
 void setEntityType(java.lang.String type)
          Sets the entity type.
 void setID(java.lang.String id)
          Sets the mention ID.
 void setPredictedEntityID(java.lang.String id)
          Sets the predicted entity ID.
 void setTrueEntityID(java.lang.String id)
          Sets the true entity ID.
 void setType(java.lang.String type)
          Sets the mention type.
 void stripID()
          Strips all identifying info that would serve as a label for coreference.
 java.lang.String toFullString()
          Gets the mention data as a full string, showing entity IDs.
 java.lang.String toFullString(boolean showEID)
          Gets the mention data as a full string.
 java.lang.String toString()
          Gets the mention as a string, with newlines replaced by spaces.
private  void writeObject(java.io.ObjectOutputStream out)
          Serialization write method.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

m_doc

private Doc m_doc

m_id

private java.lang.String m_id

m_type

private java.lang.String m_type

m_ldcType

private java.lang.String m_ldcType

m_ldcAtr

private java.lang.String m_ldcAtr

m_role

private java.lang.String m_role

m_head

private Chunk m_head

m_extent

private Chunk m_extent

m_trueEntityID

private java.lang.String m_trueEntityID

m_predEntityID

private java.lang.String m_predEntityID

m_entityType

private java.lang.String m_entityType

m_subtype

private java.lang.String m_subtype

m_specificity

private java.lang.String m_specificity

m_isTrueMention

public boolean m_isTrueMention

m_corefMents

private transient java.util.Set<Mention> m_corefMents

m_predGender

public transient char m_predGender

m_predNumber

public transient char m_predNumber

m_predwnEType

public transient java.lang.String m_predwnEType
Constructor Detail

Mention

public Mention(Doc d,
               java.lang.String id,
               java.lang.String type,
               java.lang.String ldcType,
               java.lang.String ldcAtr,
               java.lang.String role,
               Chunk extent,
               Chunk head,
               java.lang.String entityID,
               java.lang.String entityType,
               java.lang.String subtype,
               java.lang.String specificity,
               boolean isTrueMention)
A complete constructor.

Parameters:
d - The document containing this mention.
id - The mention's ID.
type - The mention's mention type (NAM, NOM, PRE, or PRO).
ldcType - The LDC Type.
ldcAtr - The LDC Attribute.
role - The role.
extent - The extent of the mention.
head - The head of the mention.
entityID - The entity ID of the entity containing this mention (PER, GPE, ORG, LOC, VEH, WEA, or FAC).
subtype - The entity sub-type.
specificity - The specificity (SPC or GEN).
isTrueMention - Whether the mention is true or predicted.

Mention

public Mention(Doc d,
               Chunk headAndExtent)
A basic constructor that assumes the head and the extent are identical. All other parameters are set to "NONE" or false.

Parameters:
d - The document containing this mention.
headAndExtent - The head and the extent (assumed to be identical).
Method Detail

getHead

public Chunk getHead()
Gets the ACE head of this mention. The head is the noun phrase that is the syntactic head of the mention.

Returns:
The head of the mention.

getExtent

public Chunk getExtent()
Gets the ACE extent of this mention. The extent is the largest noun phrase headed by the head of this mention.

Returns:
The extent of the mention.

getDoc

public Doc getDoc()
Gets the document containing this mention.

Returns:
the Doc containing this mention.

getHeadFirstWordNum

public int getHeadFirstWordNum()
Gets the position in the document of the first word in the head.

Returns:
The word number in the document of the head's first word.

getHeadLastWordNum

public int getHeadLastWordNum()
Gets the position in the document of the last word in the head.

Returns:
The word number in the document of the head's last word.

getExtentFirstWordNum

public int getExtentFirstWordNum()
Gets the position in the document of the first word in the extent.

Returns:
The word number in the document of the extent's first word.

getExtentLastWordNum

public int getExtentLastWordNum()
Gets the position in the document of the last word in the extent.

Returns:
The word number in the document of the extent's last word.

getSentNum

public int getSentNum()
Gets the sentence number of the mention, which is defined as the sentence number of the first word in the head.

Returns:
The sentence number.

getID

public java.lang.String getID()
Gets the mention ID of this mention.

Returns:
the mention ID, which is not the same as the entity ID.

setID

public void setID(java.lang.String id)
Sets the mention ID.

Parameters:
id - The new ID.

getEntityID

public java.lang.String getEntityID()
Gets the entity ID.

Returns:
the predicted entityID if available and not "NONE", else return the true entityID if available and not "NONE", else return "NONE".

getPredictedEntityID

public java.lang.String getPredictedEntityID()
Gets the predicted entity ID, which may be NONE.

Returns:
The predicted entity ID.

setPredictedEntityID

public void setPredictedEntityID(java.lang.String id)
Sets the predicted entity ID.

Parameters:
id - The new predicted entity ID.

getTrueEntityID

public java.lang.String getTrueEntityID()
Get the true entity ID.

Returns:
The true entity ID, or "NONE" or null if no true entity ID has been set.

setTrueEntityID

public void setTrueEntityID(java.lang.String id)
Sets the true entity ID.

Parameters:
id - The true Entity ID.

stripID

public void stripID()
Strips all identifying info that would serve as a label for coreference.


getType

public java.lang.String getType()
Gets the mention type.

Returns:
The Mention Type (NAM, NOM, PRE, PRO, or NONE).

setType

public void setType(java.lang.String type)
Sets the mention type.

Parameters:
type - The mention type (NAM, NOM, PRE, PRO, or NONE).

getEntityType

public java.lang.String getEntityType()
Gets the entity type.

Returns:
The Entity Type, PER, LOC, ORG, GPE, WEA, VEH, or FAC.

setEntityType

public void setEntityType(java.lang.String type)
Sets the entity type.

Parameters:
type - The entity type.

getSubtype

public java.lang.String getSubtype()
Gets the entity subtype for this mention.

Returns:
The entity subtype.

getLdcType

public java.lang.String getLdcType()

getSpecificity

public java.lang.String getSpecificity()
Gets the specificity.

Returns:
The Specificity of the Mention, either Generic ("GEN") or Specific ("SPC").

getLdcAtr

public java.lang.String getLdcAtr()
Get the LDC Attribute.

Returns:
The LDC Attribute.

getRole

public java.lang.String getRole()
Get the role.

Returns:
The role.

getCorefMents

public java.util.Set<Mention> getCorefMents()
Gets the set of mentions known (or believed) to be coreferential with this mention. Includes this. Backed internally. Note: Not all of this project records coreferential mentions for access here.


addCorefMent

public void addCorefMent(Mention m)
Adds a mention to the set of mentions coreferential with this. Note: Not all of this project records coreferential mentions using this and related methods.

Parameters:
m - The mention coreferential with this.

addCorefMentsOf

public void addCorefMentsOf(Mention m)
Adds all the mentions known (or believed) to be coreferential with m to the set of mentions coreferential with this. After this method is called, this.getCorefMents() will also contain all the mentions in m.getCorefMents() (in addition to any other mentions already included). Note: Not all of this project records coreferential mentions using this and related methods.

Parameters:
m - The target mention.

equals

public boolean equals(java.lang.Object o)
equals and hashCode methods inspired by article hosted on Technofundo, called "Equals and Hash Code", by Manish Hatwalne Available as of Feb. 27 2007 at URL: http://www.geocities.com/technofundo/tech/java/equalhash.html NOTE: comparison is by head and extent only (but this is subject to change).

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Gets the hash code, which takes into account the hash codes of the head and extent, but NOT the ID or any other metadata.

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(Mention m)
Compare first by extent, then by head.

Specified by:
compareTo in interface java.lang.Comparable<Mention>

toString

public java.lang.String toString()
Gets the mention as a string, with newlines replaced by spaces.

Overrides:
toString in class java.lang.Object

toFullString

public java.lang.String toFullString()
Gets the mention data as a full string, showing entity IDs.

Returns:
The mention data as a string.

toFullString

public java.lang.String toFullString(boolean showEID)
Gets the mention data as a full string.

Parameters:
showEID - Whether the Entity IDs should be included.
Returns:
The mention data as a string.

getText

public java.lang.String getText()
Gets the mention as a string, with vertical bars marking the head unless the extent and head are identical, and with newlines replaced by spaces.

Returns:
The mention text.

getPreHeadText

public java.lang.String getPreHeadText()
Gets the text up to but not including the head. Includes any trailing spaces.

Returns:
the text before the head of this mention.

getThruHeadText

public java.lang.String getThruHeadText()
Gets the text up to and including the head.

Returns:
The text up to and including the head.

writeObject

private void writeObject(java.io.ObjectOutputStream out)
                  throws java.io.IOException
Serialization write method.

Parameters:
out - The stream to write to.
Throws:
java.io.IOException

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Serialization read method.

Parameters:
in - The stream to read from.
Throws:
java.io.IOException
java.lang.ClassNotFoundException