Class MecabDictionaryInstaller
ResourceInstaller under ResourceInstaller.Limits.DEFAULT, including
startup property overrides. An http or https archive requires an
expected checksum, and the ustar, pax, and GNU tar formats are all read. Catalog
installs are opt-in via
installFromCatalog(DictionaryCatalog, String, Path).
Only the dictionary payload is installed: the *.csv lexicon files and
*.def definition files that a MecabDictionary reads, plus the
dicrc configuration file distributions ship alongside them, taken from the
archive root only (at most one leading directory deep). Deeper entries are skipped:
mecab-ko-dic, for example, nests user-dic templates whose numeric fields are
empty because they are input for mecab-dict-index, not loadable lexicon
data. Installed files are flattened to their base names. A file whose base name
already exists in the target is not replaced, so it must be removed before refreshing
a dictionary. The archive unpacks into a hidden scratch directory beneath the target,
on the target's filesystem, which is removed when the installation ends.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic intUnpacks a localfile:archive URI.static intDownloads a dictionary archive when needed, verifies its checksum, and unpacks it throughResourceInstaller.install(URI, Path, String).static intinstallFromCatalog(DictionaryCatalog catalog, String dictionaryId, Path targetDirectory) Downloads a dictionary named in an application-suppliedDictionaryCatalogand unpacks it.
-
Method Details
-
install
Unpacks a localfile:archive URI. Any other scheme requiresinstall(URI, Path, String)with an expected checksum.- Parameters:
archive- The archive location, a gzip-compressed tar. Must not benull.targetDirectory- The directory to unpack into; created when absent. Must not benull.- Returns:
- The number of dictionary files installed.
- Throws:
IOException- Thrown if reading or writing fails, the archive contains no dictionary file, an installation limit is exceeded, or the target already contains one of the files.IllegalArgumentException- Thrown if a parameter isnullorarchivedoes not use thefilescheme.
-
install
public static int install(URI archive, Path targetDirectory, String expectedChecksum) throws IOException Downloads a dictionary archive when needed, verifies its checksum, and unpacks it throughResourceInstaller.install(URI, Path, String). Afile:URI may omit the checksum.- Parameters:
archive- The archive location, a gzip-compressed tar. Must not benull.targetDirectory- The directory to unpack into; created when absent. Must not benull.expectedChecksum- The expected digest of the archive bytes as a hex string, 64 characters for SHA-256 or 128 for SHA-512. Required for an http or https source; passnullto skip verification for a file source.- Returns:
- The number of dictionary files installed.
- Throws:
IOException- Thrown if fetching, verification, reading, or writing fails, the archive contains no dictionary file, an installation limit is exceeded, or the target already contains one of the files.IllegalArgumentException- Thrown if a parameter isnull, the URI is not supported byResourceInstaller, or an http or https source has no checksum.
-
installFromCatalog
public static int installFromCatalog(DictionaryCatalog catalog, String dictionaryId, Path targetDirectory) throws IOException Downloads a dictionary named in an application-suppliedDictionaryCatalogand unpacks it. Requires-Dopennlp.download.remote=true.- Parameters:
catalog- The application-supplied catalog. Must not benull.dictionaryId- The catalog id, for examplemecab.ipadicormecab.ko-dic. Must not benull.targetDirectory- The directory to unpack into; created when absent. Must not benull.- Returns:
- The number of dictionary files installed.
- Throws:
IOException- Thrown if the catalog entry is missing, remote downloads are disabled, or install fails.IllegalArgumentException- Thrown if a parameter isnull.
-