org.apache.ctakes.relationextractor.ae
Class RelationExtractorAnnotator

java.lang.Object
  extended by org.apache.uima.analysis_component.AnalysisComponent_ImplBase
      extended by org.apache.uima.analysis_component.Annotator_ImplBase
          extended by org.apache.uima.analysis_component.JCasAnnotator_ImplBase
              extended by org.uimafit.component.JCasAnnotator_ImplBase
                  extended by org.cleartk.classifier.CleartkAnnotator<java.lang.String>
                      extended by org.apache.ctakes.relationextractor.ae.RelationExtractorAnnotator
All Implemented Interfaces:
org.apache.uima.analysis_component.AnalysisComponent, org.uimafit.factory.initializable.Initializable
Direct Known Subclasses:
Baseline1EntityMentionPairRelationExtractorAnnotator, Baseline2DegreeOfRelationExtractorAnnotator, Baseline2EntityMentionPairRelationExtractorAnnotator, Baseline3EntityMentionPairRelationExtractorAnnotator, DegreeOfRelationExtractorAnnotator, EntityMentionPairRelationExtractorAnnotator, EventTimeRelationAnnotator

public abstract class RelationExtractorAnnotator
extends org.cleartk.classifier.CleartkAnnotator<java.lang.String>


Nested Class Summary
static class RelationExtractorAnnotator.IdentifiedAnnotationPair
           
 
Field Summary
protected  java.util.Random coin
           
static java.lang.String NO_RELATION_CATEGORY
           
static java.lang.String PARAM_PROBABILITY_OF_KEEPING_A_NEGATIVE_EXAMPLE
           
protected  double probabilityOfKeepingANegativeExample
           
 
Fields inherited from class org.cleartk.classifier.CleartkAnnotator
classifier, dataWriter, PARAM_CLASSIFIER_FACTORY_CLASS_NAME, PARAM_DATA_WRITER_FACTORY_CLASS_NAME, PARAM_IS_TRAINING
 
Constructor Summary
RelationExtractorAnnotator()
           
 
Method Summary
(package private) static void allowClassifierModelOnClasspath(org.apache.uima.UimaContext context)
          Workaround for https://code.google.com/p/cleartk/issues/detail?id=346 Not intended for external use
protected  java.lang.String classify(java.util.List<org.cleartk.classifier.Feature> features)
          Predict an outcome given a set of features.
protected  void createRelation(org.apache.uima.jcas.JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2, java.lang.String predictedCategory)
          Create a UIMA relation type based on arguments and the relation label.
protected abstract  java.util.List<RelationExtractorAnnotator.IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(org.apache.uima.jcas.JCas identifiedAnnotationView, org.apache.uima.jcas.tcas.Annotation coveringAnnotation)
          Selects the relevant mentions/annotations within a covering annotation for relation identification/extraction.
protected abstract  java.lang.Class<? extends org.apache.uima.jcas.tcas.Annotation> getCoveringClass()
           
protected  java.util.List<RelationFeaturesExtractor> getFeatureExtractors()
          Defines the list of feature extractors used by the classifier.
protected  java.lang.String getRelationCategory(java.util.Map<java.util.List<org.apache.uima.jcas.tcas.Annotation>,BinaryTextRelation> relationLookup, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2)
          Looks up the arguments in the specified lookup table and converts the relation into a label for classification
 void initialize(org.apache.uima.UimaContext context)
           
 void process(org.apache.uima.jcas.JCas jCas)
           
 
Methods inherited from class org.cleartk.classifier.CleartkAnnotator
collectionProcessComplete, isTraining
 
Methods inherited from class org.uimafit.component.JCasAnnotator_ImplBase
getLogger
 
Methods inherited from class org.apache.uima.analysis_component.JCasAnnotator_ImplBase
getRequiredCasInterface, process
 
Methods inherited from class org.apache.uima.analysis_component.Annotator_ImplBase
getCasInstancesRequired, hasNext, next
 
Methods inherited from class org.apache.uima.analysis_component.AnalysisComponent_ImplBase
batchProcessComplete, destroy, getContext, getResultSpecification, reconfigure, setResultSpecification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_RELATION_CATEGORY

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

PARAM_PROBABILITY_OF_KEEPING_A_NEGATIVE_EXAMPLE

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

probabilityOfKeepingANegativeExample

protected double probabilityOfKeepingANegativeExample

coin

protected java.util.Random coin
Constructor Detail

RelationExtractorAnnotator

public RelationExtractorAnnotator()
Method Detail

getFeatureExtractors

protected java.util.List<RelationFeaturesExtractor> getFeatureExtractors()
Defines the list of feature extractors used by the classifier. Subclasses may override this method to provide a different set of feature extractors.

Returns:
The list of feature extractors to use.

getCoveringClass

protected abstract java.lang.Class<? extends org.apache.uima.jcas.tcas.Annotation> getCoveringClass()

getCandidateRelationArgumentPairs

protected abstract java.util.List<RelationExtractorAnnotator.IdentifiedAnnotationPair> getCandidateRelationArgumentPairs(org.apache.uima.jcas.JCas identifiedAnnotationView,
                                                                                                                         org.apache.uima.jcas.tcas.Annotation coveringAnnotation)
Selects the relevant mentions/annotations within a covering annotation for relation identification/extraction.


allowClassifierModelOnClasspath

static void allowClassifierModelOnClasspath(org.apache.uima.UimaContext context)
Workaround for https://code.google.com/p/cleartk/issues/detail?id=346 Not intended for external use


initialize

public void initialize(org.apache.uima.UimaContext context)
                throws org.apache.uima.resource.ResourceInitializationException
Specified by:
initialize in interface org.apache.uima.analysis_component.AnalysisComponent
Specified by:
initialize in interface org.uimafit.factory.initializable.Initializable
Overrides:
initialize in class org.cleartk.classifier.CleartkAnnotator<java.lang.String>
Throws:
org.apache.uima.resource.ResourceInitializationException

process

public void process(org.apache.uima.jcas.JCas jCas)
             throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
Specified by:
process in class org.apache.uima.analysis_component.JCasAnnotator_ImplBase
Throws:
org.apache.uima.analysis_engine.AnalysisEngineProcessException

getRelationCategory

protected java.lang.String getRelationCategory(java.util.Map<java.util.List<org.apache.uima.jcas.tcas.Annotation>,BinaryTextRelation> relationLookup,
                                               IdentifiedAnnotation arg1,
                                               IdentifiedAnnotation arg2)
Looks up the arguments in the specified lookup table and converts the relation into a label for classification

Returns:
If this category should not be processed for training return null otherwise it returns the label sent to the datawriter

classify

protected java.lang.String classify(java.util.List<org.cleartk.classifier.Feature> features)
                             throws org.cleartk.classifier.CleartkProcessingException
Predict an outcome given a set of features. By default, this simply delegates to the object's classifier. Subclasses may override this method to implement more complex classification procedures.

Parameters:
features - The features to be classified.
Returns:
The predicted outcome (label) for the features.
Throws:
org.cleartk.classifier.CleartkProcessingException

createRelation

protected void createRelation(org.apache.uima.jcas.JCas jCas,
                              IdentifiedAnnotation arg1,
                              IdentifiedAnnotation arg2,
                              java.lang.String predictedCategory)
Create a UIMA relation type based on arguments and the relation label. This allows subclasses to create/define their own types: e.g. coreference can create CoreferenceRelation instead of BinaryTextRelation

Parameters:
jCas - - JCas object, needed to create new UIMA types
arg1 - - First argument to relation
arg2 - - Second argument to relation
predictedCategory - - Name of relation