edu.columbia.cs.ref.model
Class CandidateSentence

java.lang.Object
  extended by edu.columbia.cs.ref.model.FeaturableObject
      extended by edu.columbia.cs.ref.model.CandidateSentence
All Implemented Interfaces:
java.io.Serializable

public class CandidateSentence
extends FeaturableObject
implements java.io.Serializable

A representation of a candidate sentence. A candidate sentence is the basic structure that contains the information that is used for most of the classifier based methods.

A candidate sentence is composed by a Sentence from a given document, a list of entities that are present in the sentence. The order of these entities is very important since it defines the role that each entity performs in the relationships.

A candidate sentence can also be annotated with several relationships (necessary for training).

Since:
2011-09-27
Version:
0.1
Author:
Pablo Barrio, Goncalo Simoes
See Also:
Serialized Form

Constructor Summary
CandidateSentence(Sentence sentence, java.util.List<Entity> entities)
          Candidate sentence constructor.
 
Method Summary
 void addRelationship(Relationship rel)
          This method allows for the annotation of a candidate sentence.
 boolean equals(java.lang.Object o)
           
 Entity[] getEntities()
          This method returns an array with the ordered entities that corresponds to the tuple representation of the relationships present in this candidate sentence
 java.lang.String getId()
          Returns a string that can be used as an unique identifier of the candidate sentence.
 java.util.Set<java.lang.String> getLabels()
          This method returns all the labels that correspond to the relationships present in this candidate sentence
 Relationship getRelationship(RelationshipType t)
          Given a relationship type, it returns the relationship between the entities of the candidate sentence
 Entity getRole(RelationshipType type, java.lang.String role)
          Given a relationship type and a role, it returns the entity that is fulfilling that role in a relationship of this candidate sentence
 java.util.Collection<java.lang.String> getRoles(RelationshipType t)
          Given a relationship type, it returns a collection of roles that can be assigned for this candidate sentence
 Sentence getSentence()
          This methods gets the sentence that the candidate sentence corresponds to.
 int hashCode()
           
 void setSentence(Sentence sentence)
          This method sets the sentence that the candidate sentence corresponds to.
 
Methods inherited from class edu.columbia.cs.ref.model.FeaturableObject
getFeatures, setFeatures
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CandidateSentence

public CandidateSentence(Sentence sentence,
                         java.util.List<Entity> entities)
Candidate sentence constructor. It receives a Sentence from a given document where a given set of relationships may appear. Moreover, it receives a list of entities that are present in the sentence.

We recommend that you use the class CandidatesGenerator instead of this constructor (should it be protected?)

Parameters:
sentence -
entities -
Method Detail

addRelationship

public void addRelationship(Relationship rel)
This method allows for the annotation of a candidate sentence. It receives a relationship rel between some of the entities present in this candidate sentence. This annotation indicates that there is a relationship between these entities

Parameters:
rel - Relationship between some of the entities of this sentence

setSentence

public void setSentence(Sentence sentence)
This method sets the sentence that the candidate sentence corresponds to.

Parameters:
sentence - Sentence that the candidate sentence corresponds to

getSentence

public Sentence getSentence()
This methods gets the sentence that the candidate sentence corresponds to.

Returns:
Sentence that the candidate sentence corresponds to

getEntities

public Entity[] getEntities()
This method returns an array with the ordered entities that corresponds to the tuple representation of the relationships present in this candidate sentence

Returns:
an array of entities that is that corresponds to the tuple representation of the relationships present in this candidate sentence

getLabels

public java.util.Set<java.lang.String> getLabels()
This method returns all the labels that correspond to the relationships present in this candidate sentence

Returns:
labels that correspond to the relationships present in this candidate sentence

getRoles

public java.util.Collection<java.lang.String> getRoles(RelationshipType t)
Given a relationship type, it returns a collection of roles that can be assigned for this candidate sentence

Parameters:
t - relationship type that corresponds to a key to the relationship that we are trying to find the roles for
Returns:
a collection of strings corresponding to the labels of the roles in for this relationship type

getRole

public Entity getRole(RelationshipType type,
                      java.lang.String role)
Given a relationship type and a role, it returns the entity that is fulfilling that role in a relationship of this candidate sentence

Parameters:
type - relationship type that corresponds to a key to the relationship
role - role that we want to find out
Returns:
entity fulfilling the role in this candidate sentence

getRelationship

public Relationship getRelationship(RelationshipType t)
Given a relationship type, it returns the relationship between the entities of the candidate sentence

Parameters:
type - relationship type that corresponds to a key to the relationship
Returns:
annotation of how the entities of the candidate sentence are related for a given relationship type

hashCode

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

equals

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

getId

public java.lang.String getId()
Returns a string that can be used as an unique identifier of the candidate sentence.

This string is essentially a comma-separated string concatenation of the candidate sentence

Returns:
unique identifier of the candidate sentence