Package opennlp.uima.util
Class AnnotatorUtil
java.lang.Object
opennlp.uima.util.AnnotatorUtil
This is a utility class for Annotators.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Dictionary
createOptionalDictionary
(org.apache.uima.UimaContext context, String dictionaryParameter) Creates aDictionary
via the givenUimaContext
.static Boolean
getOptionalBooleanParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext
.static org.apache.uima.cas.Feature
getOptionalFeature
(org.apache.uima.cas.Type type, String featureName, String rangeType) Retrieves an optionalfeature parameter
of specified type.static org.apache.uima.cas.Feature
getOptionalFeatureParameter
(org.apache.uima.UimaContext context, org.apache.uima.cas.Type nameType, String featureNameParameter, String rangeTypeName) Retrieves an optionalfeature parameter
of specified type.static Float
getOptionalFloatParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext
.static Integer
getOptionalIntegerParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext
.static InputStream
getOptionalResourceAsStream
(org.apache.uima.UimaContext context, String name) Opens anInputStream
for an optional resource via the givenUimaContext
.static String[]
getOptionalStringArrayParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter array from the givenUimaContext
.static String
getOptionalStringParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext
.static org.apache.uima.cas.Type
getOptionalTypeParameter
(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter) Retrieves an optionalfeature parameter
of specified type.static Boolean
getRequiredBooleanParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static org.apache.uima.cas.Feature
getRequiredFeature
(org.apache.uima.cas.Type type, String featureName) Retrieves aFeature
for a specified type andfeatureName
, otherwise an exception is thrown.static org.apache.uima.cas.Feature
getRequiredFeature
(org.apache.uima.cas.Type type, String featureName, String rangeType) Retrieves aFeature
of the given type.static org.apache.uima.cas.Feature
getRequiredFeatureParameter
(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter) Retrieves afeature parameter
of specified type.static org.apache.uima.cas.Feature
getRequiredFeatureParameter
(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter, String rangeTypeName) Retrieves afeature parameter
of specified type.static Float
getRequiredFloatParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static Integer
getRequiredIntegerParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static String
getRequiredStringParameter
(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static org.apache.uima.cas.Type
getRequiredTypeParameter
(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter) Retrieves a type of the given name from the given type system.static InputStream
getResourceAsStream
(org.apache.uima.UimaContext context, String name) Opens anInputStream
for a resource via the givenUimaContext
.static org.apache.uima.cas.Type
Retrieves a type of the given name from the given type system.
-
Method Details
-
getType
public static org.apache.uima.cas.Type getType(org.apache.uima.cas.TypeSystem typeSystem, String name) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves a type of the given name from the given type system.- Parameters:
typeSystem
- TheTypeSystem
to use.name
- The name of the type to retrieve.- Returns:
- The
Type
for thename
. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noType
could be found.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredFeature
public static org.apache.uima.cas.Feature getRequiredFeature(org.apache.uima.cas.Type type, String featureName) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves aFeature
for a specified type andfeatureName
, otherwise an exception is thrown.- Parameters:
type
- TheType
to use.featureName
- The name of the feature to retrieve.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredFeature
public static org.apache.uima.cas.Feature getRequiredFeature(org.apache.uima.cas.Type type, String featureName, String rangeType) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves aFeature
of the given type.- Parameters:
type
- TheType
to use.featureName
- The name of the feature to retrieve.rangeType
- The expected range type.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredFeatureParameter
public static org.apache.uima.cas.Feature getRequiredFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves afeature parameter
of specified type.- Parameters:
context
- TheUimaContext
to use.type
- TheType
of theFeature
to get.featureNameParameter
- The name of the feature parameter.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredFeatureParameter
public static org.apache.uima.cas.Feature getRequiredFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter, String rangeTypeName) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves afeature parameter
of specified type.- Parameters:
context
- TheUimaContext
to use.type
- TheType
of theFeature
to get.featureNameParameter
- The name of the feature parameter.rangeTypeName
- The name of expected range type.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredTypeParameter
public static org.apache.uima.cas.Type getRequiredTypeParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves a type of the given name from the given type system.- Parameters:
context
- TheUimaContext
to use.typeSystem
- TheTypeSystem
to use.parameter
- The name of the type to retrieve.- Returns:
- The
Type
for thename
. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noType
could be found.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getRequiredStringParameter
public static String getRequiredStringParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves a required parameter from the given context.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the type to retrieve.- Returns:
- The
String
value retrieved for a specifiedparameter
from thecontext
. - Throws:
org.apache.uima.resource.ResourceInitializationException
-
getRequiredIntegerParameter
public static Integer getRequiredIntegerParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves a required parameter from the given context.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the type to retrieve.- Returns:
- The
Integer
value retrieved for a specifiedparameter
from thecontext
. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if no value} could be found.
-
getRequiredFloatParameter
public static Float getRequiredFloatParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves a required parameter from the given context.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the type to retrieve.- Returns:
- The
Float
value retrieved for a specifiedparameter
from thecontext
. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if no value} could be found.
-
getRequiredBooleanParameter
public static Boolean getRequiredBooleanParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves a required parameter from the given context.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the type to retrieve.- Returns:
- The
Boolean
value retrieved for a specifiedparameter
from thecontext
. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if no value} could be found.
-
getOptionalFeatureParameter
public static org.apache.uima.cas.Feature getOptionalFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type nameType, String featureNameParameter, String rangeTypeName) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves an optionalfeature parameter
of specified type.- Parameters:
context
- TheUimaContext
to use.nameType
- TheType
of theFeature
to get.featureNameParameter
- The name of the feature parameter.rangeTypeName
- The name of expected range type.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getOptionalFeature
public static org.apache.uima.cas.Feature getOptionalFeature(org.apache.uima.cas.Type type, String featureName, String rangeType) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves an optionalfeature parameter
of specified type.- Parameters:
type
- TheType
of theFeature
to get.featureName
- The name of the feature parameter.rangeType
- The expected range type.- Returns:
- The
Feature
if found. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noFeature
did match.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getOptionalTypeParameter
public static org.apache.uima.cas.Type getOptionalTypeParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter) throws org.apache.uima.analysis_engine.AnalysisEngineProcessException Retrieves an optionalfeature parameter
of specified type.- Parameters:
context
- TheUimaContext
to use.typeSystem
- TheTypeSystem
to use.parameter
- The name of the type to retrieve.- Returns:
- The
Type
for thename
. - Throws:
OpenNlpAnnotatorProcessException
- Thrown if noType
could be found.org.apache.uima.analysis_engine.AnalysisEngineProcessException
-
getOptionalStringParameter
public static String getOptionalStringParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves an optional parameter from the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the parameter to retrieve.- Returns:
- The
parameter
ornull
if not set. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the parameter type was not of the expected type.
-
getOptionalStringArrayParameter
public static String[] getOptionalStringArrayParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves an optional parameter array from the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the parameter to retrieve.- Returns:
- The
parameter array
or an empty array if not set. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the parameter type was not of the expected type.
-
getOptionalIntegerParameter
public static Integer getOptionalIntegerParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves an optional parameter from the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the parameter to retrieve.- Returns:
- The
parameter
ornull
if not set. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the parameter type was not of the expected type.
-
getOptionalFloatParameter
public static Float getOptionalFloatParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves an optional parameter from the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the parameter to retrieve.- Returns:
- The
parameter
ornull
if not set. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the parameter type was not of the expected type.
-
getOptionalBooleanParameter
public static Boolean getOptionalBooleanParameter(org.apache.uima.UimaContext context, String parameter) throws org.apache.uima.resource.ResourceInitializationException Retrieves an optional parameter from the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.parameter
- The name of the parameter to retrieve.- Returns:
- The
parameter
ornull
if not set. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the parameter type was not of the expected type.
-
getResourceAsStream
public static InputStream getResourceAsStream(org.apache.uima.UimaContext context, String name) throws org.apache.uima.resource.ResourceInitializationException Opens anInputStream
for a resource via the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.name
- The name that identifies the resource.- Returns:
- A valid, open
InputStream
. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the resource could not be found.
-
getOptionalResourceAsStream
public static InputStream getOptionalResourceAsStream(org.apache.uima.UimaContext context, String name) throws org.apache.uima.resource.ResourceInitializationException Opens anInputStream
for an optional resource via the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.name
- The name that identifies the resource.- Returns:
- A valid, open
InputStream
. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the resource could not be found.
-
createOptionalDictionary
public static Dictionary createOptionalDictionary(org.apache.uima.UimaContext context, String dictionaryParameter) throws org.apache.uima.resource.ResourceInitializationException Creates aDictionary
via the givenUimaContext
.- Parameters:
context
- TheUimaContext
to use.dictionaryParameter
- The name that identifies the dictionary.- Returns:
- A valid
Dictionary
ornull
if IO errors occurred. - Throws:
org.apache.uima.resource.ResourceInitializationException
- Thrown if the resource could not be found.
-