Class DictionaryCatalog
java.lang.Object
opennlp.tools.util.DictionaryCatalog
Opt-in catalog of remote dictionary archives and companion files, loaded from
application-supplied properties containing URLs and SHA-512 digests. Fetching an
entry requires
REMOTE_DOWNLOAD_PROPERTY to be true.- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne catalog entry with a URI and the SHA-512 digest of its bytes. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property that must betruebefore a catalog entry may be fetched. -
Method Summary
Modifier and TypeMethodDescriptionLooks up one catalog entry.ids()Returns an unmodifiable set of catalog entry ids.voidInstalls a catalog entry intotargetDirectoryafter checking that remote catalog downloads are enabled.static DictionaryCatalogload(InputStream in) Loads a catalog from a properties stream.
-
Field Details
-
REMOTE_DOWNLOAD_PROPERTY
System property that must betruebefore a catalog entry may be fetched. DirectResourceInstallercalls do not require it: there the caller already supplied the URI and digest.- See Also:
-
-
Method Details
-
load
Loads a catalog from a properties stream.- Parameters:
in- The properties content. Must not benull.- Returns:
- The catalog. Never
null. - Throws:
IOException- Thrown if reading fails.IllegalArgumentException- Thrown ifinisnull.
-
ids
-
get
Looks up one catalog entry.- Parameters:
id- The entry id, for examplemecab.ipadic.- Returns:
- The entry. Never
null. - Throws:
IOException- Thrown if the entry is incomplete or invalid.IllegalArgumentException- Thrown ifidisnull.
-
install
Installs a catalog entry intotargetDirectoryafter checking that remote catalog downloads are enabled. The entry is fetched, digest-verified, and unpacked byResourceInstaller.install(URI, Path, String): an archive expands into the directory, and a plain file is stored under its source name.- Parameters:
id- The entry id. Must not benull.targetDirectory- The directory to install into; created when absent. Must not benull.- Throws:
IOException- Thrown if the property is not enabled, the entry is missing, the download fails verification, or the target already contains an installed file.IllegalArgumentException- Thrown if a parameter isnull.
-