Package opennlp.uima.util
Class AnnotatorUtil
java.lang.Object
opennlp.uima.util.AnnotatorUtil
Provides utility methods for Annotators.
-
Method Summary
Modifier and TypeMethodDescriptionstatic DictionarycreateOptionalDictionary(org.apache.uima.UimaContext context, String dictionaryParameter) Creates aDictionaryvia the givenUimaContext.static BooleangetOptionalBooleanParameter(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext.static org.apache.uima.cas.FeaturegetOptionalFeature(org.apache.uima.cas.Type type, String featureName, String rangeType) Retrieves an optionalfeature parameterof specified type.static org.apache.uima.cas.FeaturegetOptionalFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type nameType, String featureNameParameter, String rangeTypeName) Retrieves an optionalfeature parameterof specified type.static FloatgetOptionalFloatParameter(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext.static IntegergetOptionalIntegerParameter(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext.static InputStreamgetOptionalResourceAsStream(org.apache.uima.UimaContext context, String name) Opens anInputStreamfor 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 StringgetOptionalStringParameter(org.apache.uima.UimaContext context, String parameter) Retrieves an optional parameter from the givenUimaContext.static org.apache.uima.cas.TypegetOptionalTypeParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter) Retrieves an optionalfeature parameterof specified type.static BooleangetRequiredBooleanParameter(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static org.apache.uima.cas.FeaturegetRequiredFeature(org.apache.uima.cas.Type type, String featureName) Retrieves aFeaturefor a specified type andfeatureName, otherwise an exception is thrown.static org.apache.uima.cas.FeaturegetRequiredFeature(org.apache.uima.cas.Type type, String featureName, String rangeType) Retrieves aFeatureof the given type.static org.apache.uima.cas.FeaturegetRequiredFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter) Retrieves afeature parameterof specified type.static org.apache.uima.cas.FeaturegetRequiredFeatureParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.Type type, String featureNameParameter, String rangeTypeName) Retrieves afeature parameterof specified type.static FloatgetRequiredFloatParameter(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static IntegergetRequiredIntegerParameter(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static StringgetRequiredStringParameter(org.apache.uima.UimaContext context, String parameter) Retrieves a required parameter from the given context.static org.apache.uima.cas.TypegetRequiredTypeParameter(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 InputStreamgetResourceAsStream(org.apache.uima.UimaContext context, String name) Opens anInputStreamfor a resource via the givenUimaContext.static org.apache.uima.cas.TypeRetrieves 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- TheTypeSystemto use.name- The name of the type to retrieve.- Returns:
- The
Typefor thename. - Throws:
IllegalArgumentException- Thrown if parameters were invalid.OpenNlpAnnotatorProcessException- Thrown if noTypecould 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 aFeaturefor a specified type andfeatureName, otherwise an exception is thrown.- Parameters:
type- TheTypeto use.featureName- The name of the feature to retrieve.- Returns:
- The
Featureif found. - Throws:
IllegalArgumentException- Thrown if parameters were invalid.OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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 aFeatureof the given type.- Parameters:
type- TheTypeto use.featureName- The name of the feature to retrieve.rangeType- The expected range type.- Returns:
- The
Featureif found. - Throws:
IllegalArgumentException- Thrown if parameters were invalid.OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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 parameterof specified type.- Parameters:
context- TheUimaContextto use.type- TheTypeof theFeatureto get.featureNameParameter- The name of the feature parameter.- Returns:
- The
Featureif found. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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 parameterof specified type.- Parameters:
context- TheUimaContextto use.type- TheTypeof theFeatureto get.featureNameParameter- The name of the feature parameter.rangeTypeName- The name of expected range type.- Returns:
- The
Featureif found. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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- TheUimaContextto use.typeSystem- TheTypeSystemto use.parameter- The name of the type to retrieve.- Returns:
- The
Typefor thename. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noTypecould 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- TheUimaContextto use.parameter- The name of the type to retrieve.- Returns:
- The
Stringvalue retrieved for a specifiedparameterfrom 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- TheUimaContextto use.parameter- The name of the type to retrieve.- Returns:
- The
Integervalue retrieved for a specifiedparameterfrom 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- TheUimaContextto use.parameter- The name of the type to retrieve.- Returns:
- The
Floatvalue retrieved for a specifiedparameterfrom 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- TheUimaContextto use.parameter- The name of the type to retrieve.- Returns:
- The
Booleanvalue retrieved for a specifiedparameterfrom 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 parameterof specified type.- Parameters:
context- TheUimaContextto use.nameType- TheTypeof theFeatureto get.featureNameParameter- The name of the feature parameter.rangeTypeName- The name of expected range type.- Returns:
- The
Featureif found. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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 parameterof specified type.- Parameters:
type- TheTypeof theFeatureto get.featureName- The name of the feature parameter.rangeType- The expected range type.- Returns:
- The
Featureif found. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noFeaturedid 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 parameterof specified type.- Parameters:
context- TheUimaContextto use.typeSystem- TheTypeSystemto use.parameter- The name of the type to retrieve.- Returns:
- The
Typefor thename. - Throws:
OpenNlpAnnotatorProcessException- Thrown if noTypecould 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- TheUimaContextto use.parameter- The name of the parameter to retrieve.- Returns:
- The
parameterornullif 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- TheUimaContextto use.parameter- The name of the parameter to retrieve.- Returns:
- The
parameter arrayor 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- TheUimaContextto use.parameter- The name of the parameter to retrieve.- Returns:
- The
parameterornullif 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- TheUimaContextto use.parameter- The name of the parameter to retrieve.- Returns:
- The
parameterornullif 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- TheUimaContextto use.parameter- The name of the parameter to retrieve.- Returns:
- The
parameterornullif 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 anInputStreamfor a resource via the givenUimaContext.- Parameters:
context- TheUimaContextto 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 anInputStreamfor an optional resource via the givenUimaContext.- Parameters:
context- TheUimaContextto 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 aDictionaryvia the givenUimaContext.- Parameters:
context- TheUimaContextto use.dictionaryParameter- The name that identifies the dictionary.- Returns:
- A valid
Dictionaryornullif IO errors occurred. - Throws:
org.apache.uima.resource.ResourceInitializationException- Thrown if the resource could not be found.
-