public final class Dictionary extends Object
FSA
automaton and metadata describing the
internals of dictionary entries' coding (DictionaryMetadata
.
A dictionary consists of two files:
Modifier and Type | Field and Description |
---|---|
static WeakHashMap<String,Dictionary> |
defaultDictionaries
Default loaded dictionaries.
|
FSA |
fsa
FSA automaton with the compiled dictionary data. |
DictionaryMetadata |
metadata
Metadata associated with the dictionary.
|
static String |
METADATA_FILE_EXTENSION
Expected metadata file extension.
|
Constructor and Description |
---|
Dictionary(FSA fsa,
DictionaryMetadata metadata)
It is strongly recommended to use static methods in this class for
reading dictionaries.
|
Modifier and Type | Method and Description |
---|---|
static String |
getExpectedFeaturesName(String name)
Returns the expected name of the metadata file, based on the name of the
FSA dictionary file.
|
static Dictionary |
getForLanguage(String languageCode)
Return a built-in dictionary for a given ISO language code.
|
static Dictionary |
read(File fsaFile)
Attempts to load a dictionary using the path to the FSA file and the
expected metadata extension.
|
static Dictionary |
read(URL fsaURL)
Attempts to load a dictionary using the URL to the FSA file and the
expected metadata extension.
|
static Dictionary |
readAndClose(InputStream fsaData,
InputStream featuresData)
Attempts to load a dictionary from opened streams of FSA dictionary data
and associated metadata.
|
public static final String METADATA_FILE_EXTENSION
public final DictionaryMetadata metadata
public static final WeakHashMap<String,Dictionary> defaultDictionaries
public Dictionary(FSA fsa, DictionaryMetadata metadata)
fsa
- An instantiated FSA
instance.metadata
- A map of attributes describing the compression format and
other settings not contained in the FSA automaton. For an
explanation of available attributes and their possible values,
see DictionaryMetadata
.public static Dictionary read(File fsaFile) throws IOException
IOException
public static Dictionary read(URL fsaURL) throws IOException
Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension.
This method can be used to load resource-based dictionaries, but be aware of JAR resource-locking issues that arise from resource URLs.
IOException
public static Dictionary readAndClose(InputStream fsaData, InputStream featuresData) throws IOException
IOException
public static String getExpectedFeaturesName(String name)
name
and appending
METADATA_FILE_EXTENSION
.public static Dictionary getForLanguage(String languageCode)
RuntimeException
- Throws a RuntimeException
if the dictionary is not
bundled with the library.Copyright © 2016. All rights reserved.