Package net.didion.jwnl.dictionary
Class FileBackedDictionary
java.lang.Object
net.didion.jwnl.dictionary.Dictionary
net.didion.jwnl.dictionary.AbstractCachingDictionary
net.didion.jwnl.dictionary.FileBackedDictionary
- All Implemented Interfaces:
Installable
A
Dictionary
that retrieves objects from the text files
in the WordNet distribution directory.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate class
A lookahead iterator over a dictionary file.private class
private class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileManager
private FileDictionaryElementFactory
private static final MessageLog
static final String
The default cache size.static final String
The class of FileDictionaryElementFactory to use.static final String
The value should be "true" or "false".static final String
Size of the exception cache.static final String
File manager install parameter.static final String
Size of the index word cache.static final String
Morphological processor class install parameter.private Map
A sense map, key is offsetlemma, word is populated with lemma, usage, and sense key.static final String
Size of the synset cache. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
FileBackedDictionary
(FileManager manager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shut down the dictionarygetException
(POS pos, String derivation) Lookupderivation
in the exceptions file of part-of-speechpos
and return an Exc object containing the results.getExceptionIterator
(POS pos) Return an Iterator over all the Exceptions in the database.protected FileManager
Get the file manager that backs this database.getIndexWord
(POS pos, String lemma) Look up a word in the database.getIndexWordIterator
(POS pos) Return an Iterator over all the IndexWords of part-of-speech pos in the database.getIndexWordIterator
(POS pos, String substring) Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.getRandomIndexWord
(POS pos) private Synset
getSynsetAt
(POS pos, long offset) Return theSynset
at offsetoffset
from the database.getSynsetIterator
(POS pos) Return an Iterator over all the Synsets of part-of-speech pos in the database.void
Install a FileBackedDictionary from a map of parameters.static void
install
(FileManager fileManager, FileDictionaryElementFactory factory) Construct a Dictionary that retrieves file data fromfileManager
.static void
install
(FileManager fileManager, FileDictionaryElementFactory factory, boolean enableCaching) static void
install
(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory) Construct a Dictionary that retrieves file data fromfileManager
.static void
install
(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching) private Exc
parseAndCacheExceptionLine
(POS pos, long offset, String line) private IndexWord
parseAndCacheIndexWordLine
(POS pos, long offset, String line) Methods inherited from class net.didion.jwnl.dictionary.AbstractCachingDictionary
cacheException, cacheIndexWord, cacheSynset, clearCache, clearCache, getCacheCapacity, getCachedException, getCachedIndexWord, getCachedSynset, getCacheSizes, isCachingEnabled, setCacheCapacity, setCacheCapacity, setCachingEnabled
Methods inherited from class net.didion.jwnl.dictionary.Dictionary
getInstance, getMorphologicalProcessor, lookupAllIndexWords, lookupIndexWord, prepareQueryString, setDictionary, uninstall
-
Field Details
-
_log
-
MORPH
Morphological processor class install parameter. The value should be the class of MorphologicalProcessor to use.- See Also:
-
FILE_MANAGER
File manager install parameter. The value should be the class of FileManager to use.- See Also:
-
DICTIONARY_ELEMENT_FACTORY
The class of FileDictionaryElementFactory to use.- See Also:
-
ENABLE_CACHING
The value should be "true" or "false". The default is "true".- See Also:
-
CACHE_SIZE
The default cache size.- See Also:
-
INDEX_WORD_CACHE_SIZE
Size of the index word cache. Overrides the default cache size- See Also:
-
SYNSET_WORD_CACHE_SIZE
Size of the synset cache. Overrides the default cache size- See Also:
-
EXCEPTION_WORD_CACHE_SIZE
Size of the exception cache. Overrides the default cache size- See Also:
-
senseMap
A sense map, key is offsetlemma, word is populated with lemma, usage, and sense key. -
_db
-
_factory
-
-
Constructor Details
-
FileBackedDictionary
public FileBackedDictionary() -
FileBackedDictionary
private FileBackedDictionary(FileManager manager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching)
-
-
Method Details
-
install
Construct a Dictionary that retrieves file data fromfileManager
. A client can use this to create a Dictionary backed by a RemoteFileManager.- See Also:
-
install
public static void install(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory) Construct a Dictionary that retrieves file data fromfileManager
. If enableCaching is true, lookup operations will check the relavant cache before doing a lookup and will cache their results after doing a lookup. -
install
public static void install(FileManager fileManager, FileDictionaryElementFactory factory, boolean enableCaching) -
install
public static void install(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching) -
install
Install a FileBackedDictionary from a map of parameters. The keys are chose from the static variables above.- Throws:
JWNLException
-
close
public void close()Description copied from class:Dictionary
Shut down the dictionary- Specified by:
close
in classDictionary
-
getFileManager
Get the file manager that backs this database. -
getDictionaryElementFactory
-
getIndexWordIterator
Description copied from class:Dictionary
Return an Iterator over all the IndexWords of part-of-speech pos in the database.- Specified by:
getIndexWordIterator
in classDictionary
- Parameters:
pos
- The part-of-speech- Returns:
- An iterator over
IndexWord
s - Throws:
JWNLException
-
getIndexWordIterator
Description copied from class:Dictionary
Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.- Specified by:
getIndexWordIterator
in classDictionary
- Parameters:
pos
- The part-of-speech.- Returns:
- An iterator over
IndexWord
s. - Throws:
JWNLException
-
getIndexWord
Description copied from class:Dictionary
Look up a word in the database. The search is case-independent, and phrases are separated by spaces ("look up", not "look_up"). Note: this method does not subject lemma to any morphological processing. If you want this, useDictionary.lookupIndexWord(POS, String)
.- Specified by:
getIndexWord
in classDictionary
- Parameters:
pos
- The part-of-speech.lemma
- The orthographic representation of the word.- Returns:
- An IndexWord representing the word, or
null
if no such entry exists. - Throws:
JWNLException
-
getRandomIndexWord
- Specified by:
getRandomIndexWord
in classDictionary
- Throws:
JWNLException
-
parseAndCacheIndexWordLine
-
getSynsetIterator
Description copied from class:Dictionary
Return an Iterator over all the Synsets of part-of-speech pos in the database.- Specified by:
getSynsetIterator
in classDictionary
- Parameters:
pos
- The part-of-speech.- Returns:
- An iterator over
Synset
s.
-
getSynsetAt
Description copied from class:Dictionary
Return theSynset
at offsetoffset
from the database.- Specified by:
getSynsetAt
in classDictionary
- Parameters:
pos
- The part-of-speech file to look inoffset
- The offset of the synset in the file- Returns:
- A synset containing the parsed line from the database
- Throws:
JWNLException
-
getSynset
- Throws:
JWNLException
-
getExceptionIterator
Description copied from class:Dictionary
Return an Iterator over all the Exceptions in the database.- Specified by:
getExceptionIterator
in classDictionary
- Parameters:
pos
- the part-of-speech- Returns:
- Iterator An iterator over
String
s
-
getException
Description copied from class:Dictionary
Lookupderivation
in the exceptions file of part-of-speechpos
and return an Exc object containing the results.- Specified by:
getException
in classDictionary
- Parameters:
pos
- the exception file to look inderivation
- the word to look up- Returns:
- Exc the Exc object
- Throws:
JWNLException
-
parseAndCacheExceptionLine
-