|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.uima.analysis_component.AnalysisComponent_ImplBase
org.apache.uima.analysis_component.Annotator_ImplBase
org.apache.uima.analysis_component.CasAnnotator_ImplBase
org.apache.uima.examples.cas.PersonTitleAnnotator
public class PersonTitleAnnotator
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 |
---|
public PersonTitleAnnotator()
Method Detail |
---|
public void initialize(UimaContext aContext) throws ResourceInitializationException
initialize
in interface AnalysisComponent
initialize
in class AnalysisComponent_ImplBase
aContext
- Provides access to services and resources managed by the framework. This includes
configuration parameters, logging, and access to external resources.
ResourceInitializationException
- if this AnalysisComponent cannot initialize successfully.BaseAnnotator.initialize(AnnotatorContext)
public void typeSystemInit(TypeSystem aTypeSystem) throws AnalysisEngineProcessException
typeSystemInit
in class CasAnnotator_ImplBase
AnalysisEngineProcessException
- if the provided type system is missing types or features required by this annotatorBaseAnnotator.typeSystemInit(TypeSystem)
public void process(CAS aCAS) throws AnalysisEngineProcessException
process
in class CasAnnotator_ImplBase
aCAS
- CAS containing document text and previously discovered annotations, and to which new
annotations are to be written.
AnalysisEngineProcessException
- if a problem occurs during processingCasAnnotator_ImplBase.process(CAS)
protected void annotateRange(CAS aCAS, java.lang.String aText, int aBeginPos)
aCAS
- the CAS in which to create new annotationsaText
- the substring of the document text within which to searchaBeginPos
- the position of this substring relative to the start of the documentprotected void annotateRange(CAS aCAS, java.lang.String aText, int aBeginPos, java.lang.String aTitleType, java.lang.String[] aTitles)
aCAS
- the CAS in which to create new annotationsaText
- the substring of the document text within which to searchaBeginPos
- the position of this substring relative to the start of the documentaTitleType
- the type of title to look for. This becomes the value of the Kind
feature.aTitles
- the exact strings to look for in the documentprotected void createAnnotation(CAS aCAS, int aBeginPos, int aEndPos, java.lang.String aTitleType)
aCAS
- the CAS in which to create the annotationaBeginPos
- the begin position of the annotation relative to the start of the documentaEndPos
- 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |