opennlp.tools.coref
Class AbstractLinker

java.lang.Object
  extended by opennlp.tools.coref.AbstractLinker
All Implemented Interfaces:
Linker
Direct Known Subclasses:
DefaultLinker

public abstract class AbstractLinker
extends Object
implements Linker

Provides a default implementation of many of the methods in Linker that most implementations of Linker will want to extend.


Field Summary
protected  String corefProject
          The name of the project where the coreference models are stored.
protected  boolean debug
          Specifies whether debug print is generated.
protected  DiscourseEntity[] entities
          Array used to store the results of each call made to the linker.
protected  HeadFinder headFinder
          The head finder used in this linker.
protected static Linker linker
          Instance used for for returning the same linker for subsequent getInstance requests.
protected  MentionFinder mentionFinder
          The mention finder used to find mentions.
protected  LinkerMode mode
          The mode in which this linker is running.
protected  boolean removeUnresolvedMentions
          Specifies whether mentions for which no resolver can be used should be added to the discourse model.
protected  String[] resolverNames
          The names of the resolvers used by this Linker.
protected  AbstractResolver[] resolvers
          The resolvers used by this Linker.
protected  int SINGULAR_PRONOUN
          The index of resolver which is used for singular pronouns.
protected  boolean useDiscourseModel
          Specifies whether coreferent mentions should be combined into a single entity.
 
Fields inherited from interface opennlp.tools.coref.Linker
COMBINED_NPS, DESCRIPTOR, ISA, NP, PRONOUN_MODIFIER, PROPER_NOUN_MODIFIER
 
Constructor Summary
AbstractLinker(String project, LinkerMode mode)
          Creates a new linker using the models in the specified project directory and using the specified mode.
AbstractLinker(String project, LinkerMode mode, boolean useDiscourseModel)
          Creates a new linker using the models in the specified project directory, using the specified mode, and combining coreferent entities based on the specified value.
 
Method Summary
protected  DiscourseEntity checkForMerges(DiscourseModel dm, DiscourseEntity[] des)
           
protected abstract  Gender computeGender(MentionContext mention)
           
protected abstract  Number computeNumber(MentionContext mention)
           
 MentionContext[] constructMentionContexts(Mention[] mentions)
          Creates mention contexts for the specified mention exents.
 DiscourseEntity[] getEntities(Mention[] mentions)
          Returns a list of entities which group the mentions into entity classes.
 HeadFinder getHeadFinder()
          Returns the head finder associated with this linker.
 MentionFinder getMentionFinder()
          Returns the mention finder for this linker.
protected  void resolve(MentionContext mention, DiscourseModel discourseModel)
          Resolves the specified mention to an entity in the specified discourse model or creates a new entity for the mention.
 void setEntities(Mention[] mentions)
          Indicated that the specified mentions can be used to train this linker.
 void train()
          Trains the linker based on the data specified via calls to setEntities.
protected  void updateExtent(DiscourseModel dm, MentionContext mention, DiscourseEntity entity, boolean useDiscourseModel)
          Updates the specified discourse model with the specified mention as coreferent with the specified entity.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mentionFinder

protected MentionFinder mentionFinder
The mention finder used to find mentions.


debug

protected boolean debug
Specifies whether debug print is generated.


mode

protected LinkerMode mode
The mode in which this linker is running.


linker

protected static Linker linker
Instance used for for returning the same linker for subsequent getInstance requests.


resolvers

protected AbstractResolver[] resolvers
The resolvers used by this Linker.


resolverNames

protected String[] resolverNames
The names of the resolvers used by this Linker.


entities

protected DiscourseEntity[] entities
Array used to store the results of each call made to the linker.


SINGULAR_PRONOUN

protected int SINGULAR_PRONOUN
The index of resolver which is used for singular pronouns.


corefProject

protected String corefProject
The name of the project where the coreference models are stored.


headFinder

protected HeadFinder headFinder
The head finder used in this linker.


useDiscourseModel

protected boolean useDiscourseModel
Specifies whether coreferent mentions should be combined into a single entity. Set this to true to combine them, false otherwise.


removeUnresolvedMentions

protected boolean removeUnresolvedMentions
Specifies whether mentions for which no resolver can be used should be added to the discourse model.

Constructor Detail

AbstractLinker

public AbstractLinker(String project,
                      LinkerMode mode)
Creates a new linker using the models in the specified project directory and using the specified mode.

Parameters:
project - The location of the models or other data needed by this linker.
mode - The mode the linker should be run in: testing, training, or evaluation.

AbstractLinker

public AbstractLinker(String project,
                      LinkerMode mode,
                      boolean useDiscourseModel)
Creates a new linker using the models in the specified project directory, using the specified mode, and combining coreferent entities based on the specified value.

Parameters:
project - The location of the models or other data needed by this linker.
mode - The mode the linker should be run in: testing, training, or evaluation.
useDiscourseModel - Specifies whether coreferent mention should be combined or not.
Method Detail

resolve

protected void resolve(MentionContext mention,
                       DiscourseModel discourseModel)
Resolves the specified mention to an entity in the specified discourse model or creates a new entity for the mention.

Parameters:
mention - The mention to resolve.
discourseModel - The discourse model of existing entities.

getHeadFinder

public HeadFinder getHeadFinder()
Description copied from interface: Linker
Returns the head finder associated with this linker.

Specified by:
getHeadFinder in interface Linker
Returns:
The head finder associated with this linker.

updateExtent

protected void updateExtent(DiscourseModel dm,
                            MentionContext mention,
                            DiscourseEntity entity,
                            boolean useDiscourseModel)
Updates the specified discourse model with the specified mention as coreferent with the specified entity.

Parameters:
dm - The discourse model
mention - The mention to be added to the specified entity.
entity - The entity which is mentioned by the specified mention.
useDiscourseModel - Whether the mentions should be kept as an entiy or simply co-indexed.

checkForMerges

protected DiscourseEntity checkForMerges(DiscourseModel dm,
                                         DiscourseEntity[] des)

getEntities

public DiscourseEntity[] getEntities(Mention[] mentions)
Description copied from interface: Linker
Returns a list of entities which group the mentions into entity classes.

Specified by:
getEntities in interface Linker
Parameters:
mentions - A array of mentions.
Returns:
An array of discourse entities.

setEntities

public void setEntities(Mention[] mentions)
Description copied from interface: Linker
Indicated that the specified mentions can be used to train this linker. This requires that the coreference relationship between the mentions have been labeled in the mention's id field.

Specified by:
setEntities in interface Linker
Parameters:
mentions - The mentions to be used to train the linker.

train

public void train()
           throws IOException
Description copied from interface: Linker
Trains the linker based on the data specified via calls to setEntities.

Specified by:
train in interface Linker
Throws:
IOException

getMentionFinder

public MentionFinder getMentionFinder()
Description copied from interface: Linker
Returns the mention finder for this linker. This can be used to get the mentions of a Parse.

Specified by:
getMentionFinder in interface Linker
Returns:
The object which finds mentions for this linker.

constructMentionContexts

public MentionContext[] constructMentionContexts(Mention[] mentions)
Description copied from interface: Linker
Creates mention contexts for the specified mention exents. These are used to compute coreference features over.

Specified by:
constructMentionContexts in interface Linker
Parameters:
mentions - The mention of a document.
Returns:
mention contexts for the specified mention exents.

computeGender

protected abstract Gender computeGender(MentionContext mention)

computeNumber

protected abstract Number computeNumber(MentionContext mention)


Copyright © 2010. All Rights Reserved.