net.didion.jwnl.dictionary
Class FileBackedDictionary

java.lang.Object
  extended by net.didion.jwnl.dictionary.Dictionary
      extended by net.didion.jwnl.dictionary.AbstractCachingDictionary
          extended by net.didion.jwnl.dictionary.FileBackedDictionary
All Implemented Interfaces:
Installable

public class FileBackedDictionary
extends AbstractCachingDictionary

A Dictionary that retrieves objects from the text files in the WordNet distribution directory.


Field Summary
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.
static java.lang.String SYNSET_WORD_CACHE_SIZE
          Size of the synset cache.
 
Constructor Summary
FileBackedDictionary()
           
 
Method Summary
 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.
 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)
           
 java.lang.String getSenseKey(long offset, java.lang.String lemma)
          Gets the sense key for this combination.
 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.
 int getUsageCount(long offset, java.lang.String lemma)
          Gets the usage count for this offset/lemma combination.
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.
 
Methods inherited from class net.didion.jwnl.dictionary.AbstractCachingDictionary
clearCache, clearCache, getCacheCapacity, getCacheSizes, isCachingEnabled, setCacheCapacity, setCacheCapacity, setCachingEnabled
 
Methods inherited from class net.didion.jwnl.dictionary.Dictionary
getInstance, getMorphologicalProcessor, lookupAllIndexWords, lookupIndexWord, uninstall
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MORPH

public static final java.lang.String MORPH
Morphological processor class install parameter. The value should be the class of MorphologicalProcessor to use.

See Also:
Constant Field Values

FILE_MANAGER

public static final java.lang.String FILE_MANAGER
File manager install parameter. The value should be the class of FileManager to use.

See Also:
Constant Field Values

DICTIONARY_ELEMENT_FACTORY

public static final java.lang.String DICTIONARY_ELEMENT_FACTORY
The class of FileDictionaryElementFactory to use.

See Also:
Constant Field Values

ENABLE_CACHING

public static final java.lang.String ENABLE_CACHING
The value should be "true" or "false". The default is "true".

See Also:
Constant Field Values

CACHE_SIZE

public static final java.lang.String CACHE_SIZE
The default cache size.

See Also:
Constant Field Values

INDEX_WORD_CACHE_SIZE

public static final java.lang.String INDEX_WORD_CACHE_SIZE
Size of the index word cache. Overrides the default cache size

See Also:
Constant Field Values

SYNSET_WORD_CACHE_SIZE

public static final java.lang.String SYNSET_WORD_CACHE_SIZE
Size of the synset cache. Overrides the default cache size

See Also:
Constant Field Values

EXCEPTION_WORD_CACHE_SIZE

public static final java.lang.String EXCEPTION_WORD_CACHE_SIZE
Size of the exception cache. Overrides the default cache size

See Also:
Constant Field Values
Constructor Detail

FileBackedDictionary

public FileBackedDictionary()
Method Detail

install

public static void install(FileManager fileManager,
                           FileDictionaryElementFactory factory)
Construct a Dictionary that retrieves file data from fileManager. A client can use this to create a Dictionary backed by a RemoteFileManager.

See Also:
RemoteFileManager

install

public static void install(FileManager fileManager,
                           MorphologicalProcessor morph,
                           FileDictionaryElementFactory factory)
Construct a Dictionary that retrieves file data from 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.


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

public void install(java.util.Map params)
             throws JWNLException
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 class Dictionary

getDictionaryElementFactory

public FileDictionaryElementFactory getDictionaryElementFactory()

getIndexWordIterator

public java.util.Iterator getIndexWordIterator(POS pos)
                                        throws JWNLException
Description copied from class: Dictionary
Return an Iterator over all the IndexWords of part-of-speech pos in the database.

Specified by:
getIndexWordIterator in class Dictionary
Parameters:
pos - The part-of-speech
Returns:
An iterator over IndexWords
Throws:
JWNLException

getIndexWordIterator

public java.util.Iterator getIndexWordIterator(POS pos,
                                               java.lang.String substring)
                                        throws JWNLException
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 class Dictionary
Parameters:
pos - The part-of-speech.
Returns:
An iterator over IndexWords.
Throws:
JWNLException

getIndexWord

public IndexWord getIndexWord(POS pos,
                              java.lang.String lemma)
                       throws JWNLException
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, use Dictionary.lookupIndexWord(POS, String).

Specified by:
getIndexWord in class Dictionary
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

public IndexWord getRandomIndexWord(POS pos)
                             throws JWNLException
Specified by:
getRandomIndexWord in class Dictionary
Throws:
JWNLException

getSynsetIterator

public java.util.Iterator getSynsetIterator(POS pos)
Description copied from class: Dictionary
Return an Iterator over all the Synsets of part-of-speech pos in the database.

Specified by:
getSynsetIterator in class Dictionary
Parameters:
pos - The part-of-speech.
Returns:
An iterator over Synsets.

getSynsetAt

public Synset getSynsetAt(POS pos,
                          long offset)
                   throws JWNLException
Description copied from class: Dictionary
Return the Synset at offset offset from the database.

Specified by:
getSynsetAt in class Dictionary
Parameters:
pos - The part-of-speech file to look in
offset - The offset of the synset in the file
Returns:
A synset containing the parsed line from the database
Throws:
JWNLException

getExceptionIterator

public java.util.Iterator getExceptionIterator(POS pos)
Description copied from class: Dictionary
Return an Iterator over all the Exceptions in the database.

Specified by:
getExceptionIterator in class Dictionary
Parameters:
pos - the part-of-speech
Returns:
Iterator An iterator over Strings

getException

public Exc getException(POS pos,
                        java.lang.String derivation)
                 throws JWNLException
Description copied from class: Dictionary
Lookup derivation in the exceptions file of part-of-speech pos and return an Exc object containing the results.

Specified by:
getException in class Dictionary
Parameters:
pos - the exception file to look in
derivation - the word to look up
Returns:
Exc the Exc object
Throws:
JWNLException

getUsageCount

public int getUsageCount(long offset,
                         java.lang.String lemma)
Gets the usage count for this offset/lemma combination.

Specified by:
getUsageCount in class Dictionary
Returns:

getSenseKey

public java.lang.String getSenseKey(long offset,
                                    java.lang.String lemma)
Gets the sense key for this combination.

Specified by:
getSenseKey in class Dictionary
Returns: