Package opennlp.tools.models.dir
Class DirectoryModelFinder
java.lang.Object
opennlp.tools.models.AbstractClassPathModelFinder
opennlp.tools.models.dir.DirectoryModelFinder
- All Implemented Interfaces:
ClassPathModelFinder
public class DirectoryModelFinder
extends AbstractClassPathModelFinder
implements ClassPathModelFinder
The
DirectoryModelFinder class is responsible for finding model files in a given directory
on the classpath.
This class allows searching for models based on wildcard patterns, either in plain directory structures or within JAR files. The search can be performed recursively depending on the specified configuration.
Usage:
- Provide the prefix for models to be found in JAR files using the
jarModelPrefixparameter. - Specify the directory to search and whether to enable recursive scanning.
- The class supports resolving both direct file matches and entries within JAR archives.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Pathprivate static final org.slf4j.Loggerprivate final booleanFields inherited from class opennlp.tools.models.AbstractClassPathModelFinder
JARFields inherited from interface opennlp.tools.models.ClassPathModelFinder
OPENNLP_MODEL_JAR_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionDirectoryModelFinder(String jarModelPrefix, Path directory, boolean recursive) Instantiates a newDirectoryModelFinderwith the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgetMatchingURIs(String wildcardPattern, Object context) Retrieve matching classpathURIsfor the givenwildcardPattern.Methods inherited from class opennlp.tools.models.AbstractClassPathModelFinder
findModels, getJarModelPrefix, getMatchingJarEntryURIs, getURIsFromJar, isWindows, jarPathsMatch, matchesWildcard, parseJarURI, toURLMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface opennlp.tools.models.ClassPathModelFinder
findModels
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
directory
-
recursive
private final boolean recursive
-
-
Constructor Details
-
DirectoryModelFinder
Instantiates a newDirectoryModelFinderwith the specified parameters.- Parameters:
jarModelPrefix- The prefix for identifying model files in JAR archives; may benull. If it isnull,ClassPathModelFinder.OPENNLP_MODEL_JAR_PREFIXis used.directory- The root directory to scan from for model files; must not benull.recursive-trueif the search should include subdirectories,falseotherwise.- Throws:
IllegalArgumentException- Thrown ifdirectoryisnull.
-
-
Method Details
-
getContext
- Specified by:
getContextin classAbstractClassPathModelFinder- Returns:
- Always
nullas it is not needed for the directory case.
-
getMatchingURIs
Retrieve matching classpathURIsfor the givenwildcardPattern.- Specified by:
getMatchingURIsin classAbstractClassPathModelFinder- Parameters:
wildcardPattern- The pattern to use for scanning. Must not benull.context- An object holding context information. It might benull.- Returns:
- A list of matching classpath URIs.
-
getDirectoryContent
-