org.apache.ctakes.necontexts
Class ContextAnnotator

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.apache.ctakes.necontexts.ContextAnnotator
All Implemented Interfaces:
org.apache.uima.analysis_component.AnalysisComponent

public class ContextAnnotator
extends org.apache.uima.analysis_component.JCasAnnotator_ImplBase

The context annotator iterates through focus annotations and analyzes the surrounding context of each. The context is defined by a scope, window, and a maximum size (if applicable). The context can be further refined by boundary conditions as specified by the context analyzer used. For each focus annotation, a context is collected as a set of context annotations for each scope that is to be applied. The context annotations are passed to a context analyzer for analysis. If the context analyzer finds something of interest in the context annotations, then it will generate a context hit. Context hits are then passed to a context hit consumer which will perform an action on the hit such as updating an existing annotation or creating a new one.


Field Summary
static int ALL_SCOPE
          The ALL_SCOPE scope provides the context annotation that are found in all three of the other scopes (LEFT, MIDDLE, and RIGHT).
static String CONTEXT_ANALYZER_CLASS_PARAM
          "ContextAnalyzerClass" is a required, single, string parameter that specifies the context analyzer class that determines if a "hit" is found within a processed scope.
static String CONTEXT_ANNOTATION_CLASS_PARAM
          "ContextAnnotationClass" is a required, single, string parameter that specifies the annotation type of the context annotations (often "tokens") that make up the context relative to a focus annotation within a scope that is being examined.
static String CONTEXT_HIT_CONSUMER_CLASS_PARAM
          "ContextHitConsumerClass" is a required, single, string parameter that specifies the context hit consumer class that will process context hits that are found.
protected  ContextAnalyzer contextAnalyzer
           
protected  ContextHitConsumer contextConsumer
           
static String FOCUS_ANNOTATION_CLASS_PARAM
          "FocusAnnotationClass" is a required, single, string parameter that specifies the annotation type of the focus annotations that are going to be examined by this annotator.
static int LEFT_SCOPE
           
protected  int leftScopeSize
           
static String MAX_LEFT_SCOPE_SIZE_PARAM
          "MaxLeftScopeSize" is a required, single, integer parameter that specifies the maximum size of the left scope.
static String MAX_RIGHT_SCOPE_SIZE_PARAM
          "MaxRightScopeSize" is a required, single, integer parameter that specifies the maximum size of the right scope.
static int MIDDLE_SCOPE
          Provides context annotations that are "inside" the focus annotation.
static int RIGHT_SCOPE
           
protected  int rightScopeSize
           
static String SCOPE_ORDER_PARAM
          "ScopeOrder" is a required, multiple, string parameter that specifies the order that the scopes should be processed in.
protected  List<Integer> scopes
           
static String WINDOW_ANNOTATION_CLASS_PARAM
          "WindowAnnotationClass" is a required, single, string parameter that specifies the annotation type of the windows that specify the hard boundaries of scopes.
 
Constructor Summary
ContextAnnotator()
           
 
Method Summary
protected  List<org.apache.uima.jcas.tcas.Annotation> getLeftScopeContextAnnotations(org.apache.uima.jcas.JCas jCas, org.apache.uima.jcas.tcas.Annotation focus, org.apache.uima.jcas.tcas.Annotation window)
           
protected  List<org.apache.uima.jcas.tcas.Annotation> getMiddleScopeContextAnnotations(org.apache.uima.jcas.JCas jCas, org.apache.uima.jcas.tcas.Annotation focus)
           
protected  List<org.apache.uima.jcas.tcas.Annotation> getRightScopeContextAnnotations(org.apache.uima.jcas.JCas jCas, org.apache.uima.jcas.tcas.Annotation focus, org.apache.uima.jcas.tcas.Annotation window)
           
protected  List<org.apache.uima.jcas.tcas.Annotation> getScopeContextAnnotations(org.apache.uima.jcas.JCas jCas, org.apache.uima.jcas.tcas.Annotation focus, org.apache.uima.jcas.tcas.Annotation window, int scope)
           
 void initialize(org.apache.uima.UimaContext uimaContext)
           
 void process(org.apache.uima.jcas.JCas jCas)
           
 
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, collectionProcessComplete, 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

MAX_LEFT_SCOPE_SIZE_PARAM

public static final String MAX_LEFT_SCOPE_SIZE_PARAM
"MaxLeftScopeSize" is a required, single, integer parameter that specifies the maximum size of the left scope.

See Also:
Constant Field Values

MAX_RIGHT_SCOPE_SIZE_PARAM

public static final String MAX_RIGHT_SCOPE_SIZE_PARAM
"MaxRightScopeSize" is a required, single, integer parameter that specifies the maximum size of the right scope.

See Also:
Constant Field Values

SCOPE_ORDER_PARAM

public static final String SCOPE_ORDER_PARAM
"ScopeOrder" is a required, multiple, string parameter that specifies the order that the scopes should be processed in. Possible values are "LEFT", "MIDDLE", "RIGHT", and "ALL".

See Also:
Constant Field Values

WINDOW_ANNOTATION_CLASS_PARAM

public static final String WINDOW_ANNOTATION_CLASS_PARAM
"WindowAnnotationClass" is a required, single, string parameter that specifies the annotation type of the windows that specify the hard boundaries of scopes. Note that the entire window may not be used depending on the location of the focus annotation, the maximum scope size, and the boundary conditions specified by the context analyzer. A window encompasses all of the scopes (left, middle, and right). Examples of likely window types would be:

See Also:
DocumentAnnotation, edu.mayo.bmi.common.type.Sentence, edu.mayo.bmi.common.type.Segment, Constant Field Values

FOCUS_ANNOTATION_CLASS_PARAM

public static final String FOCUS_ANNOTATION_CLASS_PARAM
"FocusAnnotationClass" is a required, single, string parameter that specifies the annotation type of the focus annotations that are going to be examined by this annotator. Examples of likely focus types would be:

See Also:
edu.mayo.bmi.common.type.NamedEntity, edu.mayo.bmi.common.type.BaseToken, Constant Field Values

CONTEXT_ANNOTATION_CLASS_PARAM

public static final String CONTEXT_ANNOTATION_CLASS_PARAM
"ContextAnnotationClass" is a required, single, string parameter that specifies the annotation type of the context annotations (often "tokens") that make up the context relative to a focus annotation within a scope that is being examined. The context annotations are examined for context hits by the context analyzer. Examples of likely focus types would be:

See Also:
edu.mayo.bmi.common.type.BaseToken, edu.mayo.bmi.common.type.WordToken, edu.mayo.bmi.common.type.NamedEntity, Constant Field Values

CONTEXT_ANALYZER_CLASS_PARAM

public static final String CONTEXT_ANALYZER_CLASS_PARAM
"ContextAnalyzerClass" is a required, single, string parameter that specifies the context analyzer class that determines if a "hit" is found within a processed scope.

See Also:
ContextAnalyzer, Constant Field Values

CONTEXT_HIT_CONSUMER_CLASS_PARAM

public static final String CONTEXT_HIT_CONSUMER_CLASS_PARAM
"ContextHitConsumerClass" is a required, single, string parameter that specifies the context hit consumer class that will process context hits that are found.

See Also:
ContextHitConsumer, Constant Field Values

LEFT_SCOPE

public static final int LEFT_SCOPE
See Also:
Constant Field Values

MIDDLE_SCOPE

public static final int MIDDLE_SCOPE
Provides context annotations that are "inside" the focus annotation. For example, if the focus annotation type is a named entity mention and the context annotation is a token type, then the middle scope will examine the tokens that fall within the named entity mention.

See Also:
Constant Field Values

RIGHT_SCOPE

public static final int RIGHT_SCOPE
See Also:
Constant Field Values

ALL_SCOPE

public static final int ALL_SCOPE
The ALL_SCOPE scope provides the context annotation that are found in all three of the other scopes (LEFT, MIDDLE, and RIGHT).

See Also:
Constant Field Values

leftScopeSize

protected int leftScopeSize

rightScopeSize

protected int rightScopeSize

scopes

protected List<Integer> scopes

contextAnalyzer

protected ContextAnalyzer contextAnalyzer

contextConsumer

protected ContextHitConsumer contextConsumer
Constructor Detail

ContextAnnotator

public ContextAnnotator()
Method Detail

initialize

public void initialize(org.apache.uima.UimaContext uimaContext)
                throws org.apache.uima.resource.ResourceInitializationException
Specified by:
initialize in interface org.apache.uima.analysis_component.AnalysisComponent
Overrides:
initialize in class org.apache.uima.analysis_component.AnalysisComponent_ImplBase
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

getScopeContextAnnotations

protected List<org.apache.uima.jcas.tcas.Annotation> getScopeContextAnnotations(org.apache.uima.jcas.JCas jCas,
                                                                                org.apache.uima.jcas.tcas.Annotation focus,
                                                                                org.apache.uima.jcas.tcas.Annotation window,
                                                                                int scope)
                                                                         throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
Throws:
org.apache.uima.analysis_engine.AnalysisEngineProcessException

getLeftScopeContextAnnotations

protected List<org.apache.uima.jcas.tcas.Annotation> getLeftScopeContextAnnotations(org.apache.uima.jcas.JCas jCas,
                                                                                    org.apache.uima.jcas.tcas.Annotation focus,
                                                                                    org.apache.uima.jcas.tcas.Annotation window)
                                                                             throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
Throws:
org.apache.uima.analysis_engine.AnalysisEngineProcessException

getRightScopeContextAnnotations

protected List<org.apache.uima.jcas.tcas.Annotation> getRightScopeContextAnnotations(org.apache.uima.jcas.JCas jCas,
                                                                                     org.apache.uima.jcas.tcas.Annotation focus,
                                                                                     org.apache.uima.jcas.tcas.Annotation window)
                                                                              throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
Throws:
org.apache.uima.analysis_engine.AnalysisEngineProcessException

getMiddleScopeContextAnnotations

protected List<org.apache.uima.jcas.tcas.Annotation> getMiddleScopeContextAnnotations(org.apache.uima.jcas.JCas jCas,
                                                                                      org.apache.uima.jcas.tcas.Annotation focus)
                                                                               throws org.apache.uima.analysis_engine.AnalysisEngineProcessException
Throws:
org.apache.uima.analysis_engine.AnalysisEngineProcessException


Copyright © 2012-2013 The Apache Software Foundation. All Rights Reserved.