AnnotatorUtil (Apache OpenNLP UIMA Annotators 2.5.9 API)
Description: declaration: package: opennlp.uima.util, class: AnnotatorUtil

# Class AnnotatorUtil

java.lang.Object
opennlp.uima.util.AnnotatorUtil

public final class AnnotatorUtil extends Object
Provides utility methods for Annotators.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static opennlp.tools.dictionary.Dictionary`
  `createOptionalDictionary(org.apache.uima.UimaContext context, String dictionaryParameter)`
  Creates a `Dictionary` via the given `UimaContext`.
  `static Boolean`
  `getOptionalBooleanParameter(org.apache.uima.UimaContext context, String parameter)`
  Retrieves an optional parameter from the given `UimaContext`.
  `static org.apache.uima.cas.Feature`
  `getOptionalFeature(org.apache.uima.cas.Type type, String featureName, String rangeType)`
  Retrieves an optional `feature 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 optional `feature parameter` of specified type.
  `static Float`
  `getOptionalFloatParameter(org.apache.uima.UimaContext context, String parameter)`
  Retrieves an optional parameter from the given `UimaContext`.
  `static Integer`
  `getOptionalIntegerParameter(org.apache.uima.UimaContext context, String parameter)`
  Retrieves an optional parameter from the given `UimaContext`.
  `static InputStream`
  `getOptionalResourceAsStream(org.apache.uima.UimaContext context, String name)`
  Opens an `InputStream` for an optional resource via the given `UimaContext`.
  `static String[]`
  `getOptionalStringArrayParameter(org.apache.uima.UimaContext context, String parameter)`
  Retrieves an optional parameter array from the given `UimaContext`.
  `static String`
  `getOptionalStringParameter(org.apache.uima.UimaContext context, String parameter)`
  Retrieves an optional parameter from the given `UimaContext`.
  `static org.apache.uima.cas.Type`
  `getOptionalTypeParameter(org.apache.uima.UimaContext context, org.apache.uima.cas.TypeSystem typeSystem, String parameter)`
  Retrieves an optional `feature 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 a `Feature` for a specified type and `featureName`, otherwise an exception is thrown.
  `static org.apache.uima.cas.Feature`
  `getRequiredFeature(org.apache.uima.cas.Type type, String featureName, String rangeType)`
  Retrieves a `Feature` 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 a `feature 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 a `feature 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 an `InputStream` for a resource via the given `UimaContext`.
  `static org.apache.uima.cas.Type`
  `getType(org.apache.uima.cas.TypeSystem typeSystem, String name)`
  Retrieves a type of the given name from the given type system.

  ### Methods inherited from class Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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` - The `TypeSystem` to use.
      `name` - The name of the type to retrieve.
    Returns:
      The `Type` for the `name`.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.
      `OpenNlpAnnotatorProcessException` - Thrown if no `Type` 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 a `Feature` for a specified type and `featureName`, otherwise an exception is thrown.
    Parameters:
      `type` - The `Type` to use.
      `featureName` - The name of the feature to retrieve.
    Returns:
      The `Feature` if found.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.
      `OpenNlpAnnotatorProcessException` - Thrown if no `Feature` 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 a `Feature` of the given type.
    Parameters:
      `type` - The `Type` to use.
      `featureName` - The name of the feature to retrieve.
      `rangeType` - The expected range type.
    Returns:
      The `Feature` if found.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.
      `OpenNlpAnnotatorProcessException` - Thrown if no `Feature` 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 a `feature parameter` of specified type.
    Parameters:
      `context` - The `UimaContext` to use.
      `type` - The `Type` of the `Feature` to get.
      `featureNameParameter` - The name of the feature parameter.
    Returns:
      The `Feature` if found.
    Throws:
      `OpenNlpAnnotatorProcessException` - Thrown if no `Feature` 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 a `feature parameter` of specified type.
    Parameters:
      `context` - The `UimaContext` to use.
      `type` - The `Type` of the `Feature` 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 no `Feature` 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` - The `UimaContext` to use.
      `typeSystem` - The `TypeSystem` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `Type` for the `name`.
    Throws:
      `OpenNlpAnnotatorProcessException` - Thrown if no `Type` 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` - The `UimaContext` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `String` value retrieved for a specified `parameter` from the `context`.
    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` - The `UimaContext` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `Integer` value retrieved for a specified `parameter` from the `context`.
    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` - The `UimaContext` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `Float` value retrieved for a specified `parameter` from the `context`.
    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` - The `UimaContext` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `Boolean` value retrieved for a specified `parameter` from the `context`.
    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 optional `feature parameter` of specified type.
    Parameters:
      `context` - The `UimaContext` to use.
      `nameType` - The `Type` of the `Feature` 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 no `Feature` 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 optional `feature parameter` of specified type.
    Parameters:
      `type` - The `Type` of the `Feature` to get.
      `featureName` - The name of the feature parameter.
      `rangeType` - The expected range type.
    Returns:
      The `Feature` if found.
    Throws:
      `OpenNlpAnnotatorProcessException` - Thrown if no `Feature` 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 optional `feature parameter` of specified type.
    Parameters:
      `context` - The `UimaContext` to use.
      `typeSystem` - The `TypeSystem` to use.
      `parameter` - The name of the type to retrieve.
    Returns:
      The `Type` for the `name`.
    Throws:
      `OpenNlpAnnotatorProcessException` - Thrown if no `Type` 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 given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` to use.
      `parameter` - The name of the parameter to retrieve.
    Returns:
      The `parameter` or `null` 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 given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` 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 given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` to use.
      `parameter` - The name of the parameter to retrieve.
    Returns:
      The `parameter` or `null` 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 given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` to use.
      `parameter` - The name of the parameter to retrieve.
    Returns:
      The `parameter` or `null` 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 given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` to use.
      `parameter` - The name of the parameter to retrieve.
    Returns:
      The `parameter` or `null` 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 an `InputStream` for a resource via the given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` 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 an `InputStream` for an optional resource via the given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` 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 opennlp.tools.dictionary.Dictionary createOptionalDictionary(org.apache.uima.UimaContext context, String dictionaryParameter) throws org.apache.uima.resource.ResourceInitializationException
    Creates a `Dictionary` via the given `UimaContext`.
    Parameters:
      `context` - The `UimaContext` to use.
      `dictionaryParameter` - The name that identifies the dictionary.
    Returns:
      A valid `Dictionary` or `null` if IO errors occurred.
    Throws:
      `org.apache.uima.resource.ResourceInitializationException` - Thrown if the resource could not be found.