Class MapBackedDictionary

java.lang.Object
net.didion.jwnl.dictionary.Dictionary
net.didion.jwnl.dictionary.MapBackedDictionary
All Implemented Interfaces:
Installable

public class MapBackedDictionary extends Dictionary
A Dictionary backed by Maps. Warning: this has huge memory requirements. Make sure to start the interpreter with a large enough free memory pool to accomodate this.
  • Field Details

    • _log

      private static final MessageLog _log
    • MORPH

      public static final String MORPH
      MorphologicalProcessor class install parameter. The value should be the class of MorphologicalProcessor to use.
      See Also:
    • FILE_TYPE

      public static final String FILE_TYPE
      File type install parameter. The value should be * the name of the appropriate subclass of DictionaryFileType.
      See Also:
    • PATH

      public static final String PATH
      The path of the dictionary files
      See Also:
    • _rand

      private static final Random _rand
      Random number generator used by getRandomIndexWord()
    • _tableMap

      private Map _tableMap
  • Constructor Details

  • Method Details

    • install

      public static void install(String searchDir, Class dictionaryFileType) throws JWNLException
      Throws:
      JWNLException
    • install

      public static void install(String searchDir, Class dictionaryFileType, MorphologicalProcessor morph) throws JWNLException
      Throws:
      JWNLException
    • install

      public void install(Map params) throws JWNLException
      Install a MapBackedDictionary from a map of parameters. The parameters are chosen from the static variables above.
      Throws:
      JWNLException
    • checkFileType

      private static void checkFileType(Class c)
    • getIndexWord

      public IndexWord getIndexWord(POS pos, String lemma)
      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.
    • getIndexWordIterator

      public Iterator getIndexWordIterator(POS pos, String substring)
      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.
    • getIndexWordIterator

      public Iterator getIndexWordIterator(POS pos)
      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
    • getRandomIndexWord

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

      public 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.
    • getExceptionIterator

      public 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
    • getIterator

      private Iterator getIterator(Map map)
    • getSynsetAt

      public Synset getSynsetAt(POS pos, long offset)
      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
    • getException

      public Exc getException(POS pos, String derivation)
      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
    • close

      public void close()
      Description copied from class: Dictionary
      Shut down the dictionary
      Specified by:
      close in class Dictionary
    • loadDictFile

      private Map loadDictFile(DictionaryFile file) throws JWNLException
      Throws:
      JWNLException
    • putTable

      private void putTable(POS pos, DictionaryFileType fileType, Map table)
      Use table for lookups to the file represented by pos and fileType.
    • getTable

      private Map getTable(POS pos, DictionaryFileType fileType)
    • getUsageCount

      public int getUsageCount(long offset, String lemma)
      Not implemented in Map yet.
    • getSenseKey

      public String getSenseKey(long offset, String lemma)
      Not implemented in Map yet.