Package opennlp.tools.models

# Interface ClassPathModelProvider

All Known Implementing Classes:
  `DefaultClassPathModelProvider`

public interface ClassPathModelProvider
A provider for obtaining pre-trained OpenNLP `models` from an application's classpath.

Providing models available in the classpath requires a `finder` and a `ClassPathModelLoader` at runtime. Depending on the environment, a custom `finder` can be used.

See Also:
  - `BaseModel`
  - `ClassPathModelFinder`
  - `ClassPathModelLoader`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T extends opennlp.tools.util.model.BaseModel>
  T`
  `load(String lang, opennlp.tools.models.ModelType type, Class<T> modelType)`
  Restores a `model` among all classpath models at runtime according to the specified parameters `lang` and `type`.
  `<T extends opennlp.tools.util.model.BaseModel>
  T`
  `load(String lang, opennlp.tools.models.ModelType type, Class<T> modelType, boolean reloadCache)`
  Restores a `model` among all classpath models at runtime according to the specified parameters `lang` and `type`.

- ## Method Details

  - ### load

    <T extends opennlp.tools.util.model.BaseModel> T load(String lang, opennlp.tools.models.ModelType type, Class<T> modelType) throws IOException
    Restores a `model` among all classpath models at runtime according to the specified parameters `lang` and `type`.
    Parameters:
      `lang` - The ISO language code of the requested model. If `null` or empty, the result will be `null` as well.
      `type` - The type string to narrow down the model variant. Note: Custom naming patterns can be applied here, as the `type` fragment will be used for a 'contains' check internally.
      `modelType` - The class of model type parameter `ClassPathModelProvider` to create an instance of.
    Returns:
      An model instance of type `ClassPathModelProvider`, or `null` if no match was found for the specified parameters.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.
      `IOException` - Thrown if something went wrong during reading resources from the classpath.

  - ### load

    <T extends opennlp.tools.util.model.BaseModel> T load(String lang, opennlp.tools.models.ModelType type, Class<T> modelType, boolean reloadCache) throws IOException
    Restores a `model` among all classpath models at runtime according to the specified parameters `lang` and `type`.
    Parameters:
      `lang` - The ISO language code of the requested model. If `null` or empty, the result will be `null` as well.
      `type` - The type of model to specifiy the model variant.
      `modelType` - The class of model type parameter `ClassPathModelProvider` to create an instance of.
      `reloadCache` - `true`, if the internal cache of the `ClassPathModelFinder` should explicitly be reloaded, `false` otherwise.
    Returns:
      An model instance of type `ClassPathModelProvider`, or `null` if no match was found for the specified parameters.
    Throws:
      `IllegalArgumentException` - Thrown if parameters were invalid.
      `IOException` - Thrown if something went wrong during reading resources from the classpath.