public class FileBackedDictionary extends AbstractCachingDictionary
Dictionary that retrieves objects from the text files
in the WordNet distribution directory.| Modifier and Type | Class and Description |
|---|---|
private class |
FileBackedDictionary.FileLookaheadIterator
A lookahead iterator over a dictionary file.
|
private class |
FileBackedDictionary.IndexFileLookaheadIterator |
private class |
FileBackedDictionary.SubstringIndexFileLookaheadIterator |
| Modifier and Type | Field and Description |
|---|---|
private FileManager |
_db |
private FileDictionaryElementFactory |
_factory |
private static MessageLog |
_log |
static java.lang.String |
CACHE_SIZE
The default cache size.
|
static java.lang.String |
DICTIONARY_ELEMENT_FACTORY
The class of FileDictionaryElementFactory to use.
|
static java.lang.String |
ENABLE_CACHING
The value should be "true" or "false".
|
static java.lang.String |
EXCEPTION_WORD_CACHE_SIZE
Size of the exception cache.
|
static java.lang.String |
FILE_MANAGER
File manager install parameter.
|
static java.lang.String |
INDEX_WORD_CACHE_SIZE
Size of the index word cache.
|
static java.lang.String |
MORPH
Morphological processor class install parameter.
|
private java.util.Map |
senseMap
A sense map, key is offsetlemma, word is populated with lemma, usage, and sense key.
|
static java.lang.String |
SYNSET_WORD_CACHE_SIZE
Size of the synset cache.
|
| Modifier | Constructor and Description |
|---|---|
|
FileBackedDictionary() |
private |
FileBackedDictionary(FileManager manager,
MorphologicalProcessor morph,
FileDictionaryElementFactory factory,
boolean enableCaching) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Shut down the dictionary
|
FileDictionaryElementFactory |
getDictionaryElementFactory() |
Exc |
getException(POS pos,
java.lang.String derivation)
Lookup
derivation in the exceptions file of part-of-speech
pos and return an Exc object containing the results. |
java.util.Iterator |
getExceptionIterator(POS pos)
Return an Iterator over all the Exceptions in the database.
|
protected FileManager |
getFileManager()
Get the file manager that backs this database.
|
IndexWord |
getIndexWord(POS pos,
java.lang.String lemma)
Look up a word in the database.
|
java.util.Iterator |
getIndexWordIterator(POS pos)
Return an Iterator over all the IndexWords of part-of-speech
pos in the database.
|
java.util.Iterator |
getIndexWordIterator(POS pos,
java.lang.String substring)
Return an Iterator over all the IndexWords of part-of-speech pos
whose lemmas contain substring as a substring.
|
IndexWord |
getRandomIndexWord(POS pos) |
private Synset |
getSynset(POS pos,
long offset,
java.lang.String line) |
Synset |
getSynsetAt(POS pos,
long offset)
Return the
Synset at offset offset from the database. |
java.util.Iterator |
getSynsetIterator(POS pos)
Return an Iterator over all the Synsets of part-of-speech pos
in the database.
|
static void |
install(FileManager fileManager,
FileDictionaryElementFactory factory)
Construct a Dictionary that retrieves file data from
fileManager. |
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 from
fileManager. |
static void |
install(FileManager fileManager,
MorphologicalProcessor morph,
FileDictionaryElementFactory factory,
boolean enableCaching) |
void |
install(java.util.Map params)
Install a FileBackedDictionary from a map of parameters.
|
private Exc |
parseAndCacheExceptionLine(POS pos,
long offset,
java.lang.String line) |
private IndexWord |
parseAndCacheIndexWordLine(POS pos,
long offset,
java.lang.String line) |
cacheException, cacheIndexWord, cacheSynset, clearCache, clearCache, getCacheCapacity, getCachedException, getCachedIndexWord, getCachedSynset, getCacheSizes, isCachingEnabled, setCacheCapacity, setCacheCapacity, setCachingEnabledgetInstance, getMorphologicalProcessor, lookupAllIndexWords, lookupIndexWord, prepareQueryString, setDictionary, uninstallprivate static final MessageLog _log
public static final java.lang.String MORPH
public static final java.lang.String FILE_MANAGER
public static final java.lang.String DICTIONARY_ELEMENT_FACTORY
public static final java.lang.String ENABLE_CACHING
public static final java.lang.String CACHE_SIZE
public static final java.lang.String INDEX_WORD_CACHE_SIZE
public static final java.lang.String SYNSET_WORD_CACHE_SIZE
public static final java.lang.String EXCEPTION_WORD_CACHE_SIZE
private java.util.Map senseMap
private FileManager _db
private FileDictionaryElementFactory _factory
public FileBackedDictionary()
private FileBackedDictionary(FileManager manager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching)
public static void install(FileManager fileManager, FileDictionaryElementFactory factory)
fileManager.
A client can use this to create a Dictionary backed by a RemoteFileManager.RemoteFileManagerpublic static void install(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory)
fileManager.
If enableCaching is true, lookup operations will check the relavant cache before
doing a lookup and will cache their results after doing a lookup.public static void install(FileManager fileManager, FileDictionaryElementFactory factory, boolean enableCaching)
public static void install(FileManager fileManager, MorphologicalProcessor morph, FileDictionaryElementFactory factory, boolean enableCaching)
public void install(java.util.Map params)
throws JWNLException
JWNLExceptionpublic void close()
Dictionaryclose in class Dictionaryprotected FileManager getFileManager()
public FileDictionaryElementFactory getDictionaryElementFactory()
public java.util.Iterator getIndexWordIterator(POS pos) throws JWNLException
DictionarygetIndexWordIterator in class Dictionarypos - The part-of-speechIndexWordsJWNLExceptionpublic java.util.Iterator getIndexWordIterator(POS pos, java.lang.String substring) throws JWNLException
DictionarygetIndexWordIterator in class Dictionarypos - The part-of-speech.IndexWords.JWNLExceptionpublic IndexWord getIndexWord(POS pos, java.lang.String lemma) throws JWNLException
DictionaryDictionary.lookupIndexWord(POS, String).getIndexWord in class Dictionarypos - The part-of-speech.lemma - The orthographic representation of the word.null if
no such entry exists.JWNLExceptionpublic IndexWord getRandomIndexWord(POS pos) throws JWNLException
getRandomIndexWord in class DictionaryJWNLExceptionprivate IndexWord parseAndCacheIndexWordLine(POS pos, long offset, java.lang.String line)
public java.util.Iterator getSynsetIterator(POS pos)
DictionarygetSynsetIterator in class Dictionarypos - The part-of-speech.Synsets.public Synset getSynsetAt(POS pos, long offset) throws JWNLException
DictionarySynset at offset offset from the database.getSynsetAt in class Dictionarypos - The part-of-speech file to look inoffset - The offset of the synset in the fileJWNLExceptionprivate Synset getSynset(POS pos, long offset, java.lang.String line) throws JWNLException
JWNLExceptionpublic java.util.Iterator getExceptionIterator(POS pos)
DictionarygetExceptionIterator in class Dictionarypos - the part-of-speechStringspublic Exc getException(POS pos, java.lang.String derivation) throws JWNLException
Dictionaryderivation in the exceptions file of part-of-speech
pos and return an Exc object containing the results.getException in class Dictionarypos - the exception file to look inderivation - the word to look upJWNLException