Package opennlp.tools.models
Class DefaultClassPathModelProvider
java.lang.Object
opennlp.tools.models.DefaultClassPathModelProvider
- All Implemented Interfaces:
- ClassPathModelProvider
A default implementation of 
ClassPathModelProvider which by default relies on
 SimpleClassPathModelFinder to scan for models in the current classpath.- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionInstantiates aDefaultClassPathModelProviderwith aSimpleClassPathModelFinderand uses a defaultClassPathModelLoader.DefaultClassPathModelProvider(ClassPathModelFinder finder, ClassPathModelLoader loader) Instantiates aDefaultClassPathModelProviderwith the specifiedmodelJarPattern, amodel finderand amodel loaderinstance.
- 
Method Summary
- 
Constructor Details- 
DefaultClassPathModelProviderpublic DefaultClassPathModelProvider()Instantiates aDefaultClassPathModelProviderwith aSimpleClassPathModelFinderand uses a defaultClassPathModelLoader. By default, it scans for theClassPathModelFinder.OPENNLP_MODEL_JAR_PREFIXpattern for available model jars.
- 
DefaultClassPathModelProviderInstantiates aDefaultClassPathModelProviderwith the specifiedmodelJarPattern, amodel finderand amodel loaderinstance.- Parameters:
- finder- The- ClassPathModelFinderinstance to use for this provider. It must not be- null.
- loader- The- ClassPathModelLoaderinstance to use for this provider. It must not be- null.
- Throws:
- IllegalArgumentException- Thrown if one of the specified parameters were invalid.
 
 
- 
- 
Method Details- 
loadpublic <T extends BaseModel> T load(String lang, ModelType type, Class<T> modelType) throws IOException Restores amodelamong all classpath models at runtime according to the specified parameterslangandtype.- Specified by:
- loadin interface- ClassPathModelProvider
- Parameters:
- lang- The ISO language code of the requested model. If- nullor empty, the result will be- nullas well.
- type- The type string to narrow down the model variant. Note: Custom naming patterns can be applied here, as the- typefragment will be used for a 'contains' check internally.
- modelType- The class of model type parameter- ClassPathModelProviderto create an instance of.
- Returns:
- An model instance of type ClassPathModelProvider, ornullif no match was found for the specified parameters.
- Throws:
- IOException- Thrown if something went wrong during reading resources from the classpath.
 
- 
loadpublic <T extends BaseModel> T load(String lang, ModelType type, Class<T> modelType, boolean reloadCache) throws IOException Restores amodelamong all classpath models at runtime according to the specified parameterslangandtype.- Specified by:
- loadin interface- ClassPathModelProvider
- Parameters:
- lang- The ISO language code of the requested model. If- nullor empty, the result will be- nullas well.
- type- The type of model to specifiy the model variant.
- modelType- The class of model type parameter- ClassPathModelProviderto create an instance of.
- reloadCache-- true, if the internal cache of the- ClassPathModelFindershould explicitly be reloaded,- falseotherwise.
- Returns:
- An model instance of type ClassPathModelProvider, ornullif no match was found for the specified parameters.
- Throws:
- IOException- Thrown if something went wrong during reading resources from the classpath.
 
 
-