edu.stanford.nlp.ie.machinereading.structure
Class RelationMention

java.lang.Object
  extended by edu.stanford.nlp.ie.machinereading.structure.ExtractionObject
      extended by edu.stanford.nlp.ie.machinereading.structure.RelationMention
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
EventMention

public class RelationMention
extends ExtractionObject

Each relation has a type and set of arguments

Author:
Andrey Gusev, Mihai, David McClosky
See Also:
Serialized Form

Field Summary
protected  java.util.List<java.lang.String> argNames
          List of argument names in this relation
protected  java.util.List<ExtractionObject> args
          List of arguments in this relation If unnamed, arguments MUST be stored in semantic order, e.g., ARG0 must be a person in a employed-by relation
static java.util.logging.Logger logger
           
protected  java.lang.String signature
          A signature for a given relation mention, e.g., a concatenation of type and argument strings This is used in KBP, where we merge all RelationMentions corresponding to the same abstract relation
static java.lang.String UNRELATED
           
 
Fields inherited from class edu.stanford.nlp.ie.machinereading.structure.ExtractionObject
attributeMap, extentTokenSpan, objectId, sentence, subType, type, typeProbabilities
 
Constructor Summary
RelationMention(java.lang.String objectId, CoreMap sentence, Span span, java.lang.String type, java.lang.String subtype, ExtractionObject... args)
           
RelationMention(java.lang.String objectId, CoreMap sentence, Span span, java.lang.String type, java.lang.String subtype, java.util.List<ExtractionObject> args)
           
RelationMention(java.lang.String objectId, CoreMap sentence, Span span, java.lang.String type, java.lang.String subtype, java.util.List<ExtractionObject> args, java.util.List<java.lang.String> argNames)
           
 
Method Summary
 void addArg(ExtractionObject a)
           
 boolean argsMatch(ExtractionObject... inputArgs)
           
 boolean argsMatch(java.util.List<ExtractionObject> inputArgs)
          Verifies if the two sets of arguments match
 boolean argsMatch(RelationMention rel)
           
static RelationMention createUnrelatedRelation(RelationMentionFactory factory, ExtractionObject... args)
           
static java.util.Collection<RelationMention> filterUnrelatedRelations(java.util.Collection<RelationMention> relationMentions)
           
 ExtractionObject getArg(int argpos)
           
 java.util.List<java.lang.String> getArgNames()
           
 java.util.List<ExtractionObject> getArgs()
           
 java.util.List<EntityMention> getEntityMentionArgs()
          Fetches the arguments of this relation that are entity mentions
 int getFirstSyntacticHeadPosition()
          Find the left-most position of an argument's syntactic head
 int getLastSyntacticHeadPosition()
          Find the right-most position of an argument's syntactic head
 java.lang.String getSignature()
           
 boolean isNegativeRelation()
           
static boolean isUnrelatedLabel(java.lang.String label)
           
static java.lang.String makeUniqueId()
          Creates a new unique id for a relation mention
 boolean printableObject(double beam)
           
 void removeArgument(ExtractionObject argToRemove, boolean removeParent)
           
 void removeArguments(java.util.Set<ExtractionObject> argsToRemove, boolean removeParent)
           
 boolean replaceGoldArgsWithPredicted(java.util.List<EntityMention> predictedMentions)
          Replaces the arguments of this relations with equivalent mentions from the predictedMentions list This works only for arguments that are EntityMention!
 void setArgNames(java.util.List<java.lang.String> argNames)
           
 void setArgs(java.util.List<ExtractionObject> args)
           
 void setSignature(java.lang.String s)
           
 java.lang.String toString()
           
 
Methods inherited from class edu.stanford.nlp.ie.machinereading.structure.ExtractionObject
attributeMap, concatenateTypes, equals, getDocumentId, getExtent, getExtentString, getExtentTokenEnd, getExtentTokenStart, getFullValue, getObjectId, getSentence, getSpan, getSubType, getType, getTypeProbabilities, getValue, printableObject, setExtent, setSentence, setType, setTypeProbabilities, sortByExtent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

logger

public static final java.util.logging.Logger logger

UNRELATED

public static final java.lang.String UNRELATED
See Also:
Constant Field Values

argNames

protected java.util.List<java.lang.String> argNames
List of argument names in this relation


args

protected java.util.List<ExtractionObject> args
List of arguments in this relation If unnamed, arguments MUST be stored in semantic order, e.g., ARG0 must be a person in a employed-by relation


signature

protected java.lang.String signature
A signature for a given relation mention, e.g., a concatenation of type and argument strings This is used in KBP, where we merge all RelationMentions corresponding to the same abstract relation

Constructor Detail

RelationMention

public RelationMention(java.lang.String objectId,
                       CoreMap sentence,
                       Span span,
                       java.lang.String type,
                       java.lang.String subtype,
                       java.util.List<ExtractionObject> args)

RelationMention

public RelationMention(java.lang.String objectId,
                       CoreMap sentence,
                       Span span,
                       java.lang.String type,
                       java.lang.String subtype,
                       java.util.List<ExtractionObject> args,
                       java.util.List<java.lang.String> argNames)

RelationMention

public RelationMention(java.lang.String objectId,
                       CoreMap sentence,
                       Span span,
                       java.lang.String type,
                       java.lang.String subtype,
                       ExtractionObject... args)
Method Detail

argsMatch

public boolean argsMatch(RelationMention rel)

argsMatch

public boolean argsMatch(ExtractionObject... inputArgs)

argsMatch

public boolean argsMatch(java.util.List<ExtractionObject> inputArgs)
Verifies if the two sets of arguments match

Parameters:
inputArgs - List of arguments

getArgs

public java.util.List<ExtractionObject> getArgs()

setArgs

public void setArgs(java.util.List<ExtractionObject> args)

getEntityMentionArgs

public java.util.List<EntityMention> getEntityMentionArgs()
Fetches the arguments of this relation that are entity mentions

Returns:
List of entity-mention args sorted in semantic order

getArg

public ExtractionObject getArg(int argpos)

getArgNames

public java.util.List<java.lang.String> getArgNames()

setArgNames

public void setArgNames(java.util.List<java.lang.String> argNames)

addArg

public void addArg(ExtractionObject a)

isNegativeRelation

public boolean isNegativeRelation()

getFirstSyntacticHeadPosition

public int getFirstSyntacticHeadPosition()
Find the left-most position of an argument's syntactic head


getLastSyntacticHeadPosition

public int getLastSyntacticHeadPosition()
Find the right-most position of an argument's syntactic head


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

replaceGoldArgsWithPredicted

public boolean replaceGoldArgsWithPredicted(java.util.List<EntityMention> predictedMentions)
Replaces the arguments of this relations with equivalent mentions from the predictedMentions list This works only for arguments that are EntityMention!

Parameters:
predictedMentions -

removeArgument

public void removeArgument(ExtractionObject argToRemove,
                           boolean removeParent)

removeArguments

public void removeArguments(java.util.Set<ExtractionObject> argsToRemove,
                            boolean removeParent)

printableObject

public boolean printableObject(double beam)

setSignature

public void setSignature(java.lang.String s)

getSignature

public java.lang.String getSignature()

filterUnrelatedRelations

public static java.util.Collection<RelationMention> filterUnrelatedRelations(java.util.Collection<RelationMention> relationMentions)

makeUniqueId

public static java.lang.String makeUniqueId()
Creates a new unique id for a relation mention

Returns:
the new id

createUnrelatedRelation

public static RelationMention createUnrelatedRelation(RelationMentionFactory factory,
                                                      ExtractionObject... args)

isUnrelatedLabel

public static boolean isUnrelatedLabel(java.lang.String label)


Stanford NLP Group