org.apache.uima.examples.cas
Class PersonTitleAnnotator

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.CasAnnotator_ImplBase
              extended by org.apache.uima.examples.cas.PersonTitleAnnotator
All Implemented Interfaces:
AnalysisComponent

public class PersonTitleAnnotator
extends CasAnnotator_ImplBase

An example annotator that discovers Person Titles in text and classifies them into three categories - Civilian (e.g. Mr.,Ms.), Military (e.g. Lt. Col.) , and Government (e.g. Gov., Sen.). The titles are detected using simple string matching. The strings that are matched are determined by the CivilianTitles, MilitaryTitles, and GovernmentTitles configuration parameters.

If the ContainingAnnotationType parameter is specified, this annotator will only look for titles within existing annotations of that type. This feature can be used, for example, to only match person titles within existing Person Name annotations, discovered by some annotator that has run previously.


Constructor Summary
PersonTitleAnnotator()
           
 
Method Summary
protected  void annotateRange(CAS aCAS, java.lang.String aText, int aBeginPos)
          A utility method that searches a part of the document for Person Titles.
protected  void annotateRange(CAS aCAS, java.lang.String aText, int aBeginPos, java.lang.String aTitleType, java.lang.String[] aTitles)
          A utility method that searches a part of the document for a specific kind of Person Title.
protected  void createAnnotation(CAS aCAS, int aBeginPos, int aEndPos, java.lang.String aTitleType)
          Creates an PersonTitle annotation in the CAS.
 void initialize(UimaContext aContext)
          Performs initialization logic.
 void process(CAS aCAS)
          Annotates a document.
 void typeSystemInit(TypeSystem aTypeSystem)
          Called whenever the CAS type system changes.
 
Methods inherited from class org.apache.uima.analysis_component.CasAnnotator_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
 

Constructor Detail

PersonTitleAnnotator

public PersonTitleAnnotator()
Method Detail

initialize

public void initialize(UimaContext aContext)
                throws ResourceInitializationException
Performs initialization logic. This implementation just reads values for the configuration parameters.

Specified by:
initialize in interface AnalysisComponent
Overrides:
initialize in class AnalysisComponent_ImplBase
Parameters:
aContext - Provides access to services and resources managed by the framework. This includes configuration parameters, logging, and access to external resources.
Throws:
ResourceInitializationException - if this AnalysisComponent cannot initialize successfully.
See Also:
BaseAnnotator.initialize(AnnotatorContext)

typeSystemInit

public void typeSystemInit(TypeSystem aTypeSystem)
                    throws AnalysisEngineProcessException
Called whenever the CAS type system changes. Acquires references to Types and Features.

Overrides:
typeSystemInit in class CasAnnotator_ImplBase
Throws:
AnalysisEngineProcessException - if the provided type system is missing types or features required by this annotator
See Also:
BaseAnnotator.typeSystemInit(TypeSystem)

process

public void process(CAS aCAS)
             throws AnalysisEngineProcessException
Annotates a document. This annotator searches for person titles using simple string matching.

Specified by:
process in class CasAnnotator_ImplBase
Parameters:
aCAS - CAS containing document text and previously discovered annotations, and to which new annotations are to be written.
Throws:
AnalysisEngineProcessException - if a problem occurs during processing
See Also:
CasAnnotator_ImplBase.process(CAS)

annotateRange

protected void annotateRange(CAS aCAS,
                             java.lang.String aText,
                             int aBeginPos)
A utility method that searches a part of the document for Person Titles.

Parameters:
aCAS - the CAS in which to create new annotations
aText - the substring of the document text within which to search
aBeginPos - the position of this substring relative to the start of the document

annotateRange

protected void annotateRange(CAS aCAS,
                             java.lang.String aText,
                             int aBeginPos,
                             java.lang.String aTitleType,
                             java.lang.String[] aTitles)
A utility method that searches a part of the document for a specific kind of Person Title.

Parameters:
aCAS - the CAS in which to create new annotations
aText - the substring of the document text within which to search
aBeginPos - the position of this substring relative to the start of the document
aTitleType - the type of title to look for. This becomes the value of the Kind feature.
aTitles - the exact strings to look for in the document

createAnnotation

protected void createAnnotation(CAS aCAS,
                                int aBeginPos,
                                int aEndPos,
                                java.lang.String aTitleType)
Creates an PersonTitle annotation in the CAS.

Parameters:
aCAS - the CAS in which to create the annotation
aBeginPos - the begin position of the annotation relative to the start of the document
aEndPos - the end position of the annotation relative to the start of the document. (Note that, as in the Java string functions, the end position is one past the last character in the annotation, so that (end - begin) = length.
aTitleType - the type of person title. This becomes the value of the Kind feature.


Copyright © 2010 The Apache Software Foundation. All Rights Reserved.