Package net.didion.jwnl.dictionary
Class MapBackedDictionary
- java.lang.Object
-
- net.didion.jwnl.dictionary.Dictionary
-
- net.didion.jwnl.dictionary.MapBackedDictionary
-
- All Implemented Interfaces:
Installable
public class MapBackedDictionary extends Dictionary
ADictionarybacked byMaps. Warning: this has huge memory requirements. Make sure to start the interpreter with a large enough free memory pool to accomodate this.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMapBackedDictionary.IndexWordIteratorprivate static classMapBackedDictionary.MapTableKey
-
Field Summary
Fields Modifier and Type Field Description private static MessageLog_logprivate static java.util.Random_randRandom number generator used by getRandomIndexWord()private java.util.Map_tableMapstatic java.lang.StringFILE_TYPEFile type install parameter.static java.lang.StringMORPHMorphologicalProcessorclass install parameter.static java.lang.StringPATHThe path of the dictionary files
-
Constructor Summary
Constructors Modifier Constructor Description MapBackedDictionary()privateMapBackedDictionary(DictionaryCatalogSet files, MorphologicalProcessor morph)Create aMapBackedDictionarywith the specified set of files.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static voidcheckFileType(java.lang.Class c)voidclose()Shut down the dictionaryExcgetException(POS pos, java.lang.String derivation)Lookupderivationin the exceptions file of part-of-speechposand return an Exc object containing the results.java.util.IteratorgetExceptionIterator(POS pos)Return an Iterator over all the Exceptions in the database.IndexWordgetIndexWord(POS pos, java.lang.String lemma)Look up a word in the database.java.util.IteratorgetIndexWordIterator(POS pos)Return an Iterator over all the IndexWords of part-of-speech pos in the database.java.util.IteratorgetIndexWordIterator(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.private java.util.IteratorgetIterator(java.util.Map map)IndexWordgetRandomIndexWord(POS pos)java.lang.StringgetSenseKey(long offset, java.lang.String lemma)Not implemented in Map yet.SynsetgetSynsetAt(POS pos, long offset)Return theSynsetat offsetoffsetfrom the database.java.util.IteratorgetSynsetIterator(POS pos)Return an Iterator over all the Synsets of part-of-speech pos in the database.private java.util.MapgetTable(POS pos, DictionaryFileType fileType)intgetUsageCount(long offset, java.lang.String lemma)Not implemented in Map yet.static voidinstall(java.lang.String searchDir, java.lang.Class dictionaryFileType)static voidinstall(java.lang.String searchDir, java.lang.Class dictionaryFileType, MorphologicalProcessor morph)voidinstall(java.util.Map params)Install aMapBackedDictionaryfrom a map of parameters.private java.util.MaploadDictFile(DictionaryFile file)private voidputTable(POS pos, DictionaryFileType fileType, java.util.Map table)Use table for lookups to the file represented by pos and fileType.-
Methods inherited from class net.didion.jwnl.dictionary.Dictionary
getInstance, getMorphologicalProcessor, lookupAllIndexWords, lookupIndexWord, prepareQueryString, setDictionary, uninstall
-
-
-
-
Field Detail
-
_log
private static final MessageLog _log
-
MORPH
public static final java.lang.String MORPH
MorphologicalProcessorclass install parameter. The value should be the class ofMorphologicalProcessorto use.- See Also:
- Constant Field Values
-
FILE_TYPE
public static final java.lang.String FILE_TYPE
File type install parameter. The value should be * the name of the appropriate subclass ofDictionaryFileType.- See Also:
- Constant Field Values
-
PATH
public static final java.lang.String PATH
The path of the dictionary files- See Also:
- Constant Field Values
-
_rand
private static final java.util.Random _rand
Random number generator used by getRandomIndexWord()
-
_tableMap
private java.util.Map _tableMap
-
-
Constructor Detail
-
MapBackedDictionary
public MapBackedDictionary()
-
MapBackedDictionary
private MapBackedDictionary(DictionaryCatalogSet files, MorphologicalProcessor morph) throws JWNLException
Create aMapBackedDictionarywith the specified set of files.- Throws:
JWNLException
-
-
Method Detail
-
install
public static void install(java.lang.String searchDir, java.lang.Class dictionaryFileType) throws JWNLException- Throws:
JWNLException
-
install
public static void install(java.lang.String searchDir, java.lang.Class dictionaryFileType, MorphologicalProcessor morph) throws JWNLException- Throws:
JWNLException
-
install
public void install(java.util.Map params) throws JWNLExceptionInstall aMapBackedDictionaryfrom a map of parameters. The parameters are chosen from the static variables above.- Throws:
JWNLException
-
checkFileType
private static void checkFileType(java.lang.Class c)
-
getIndexWord
public IndexWord getIndexWord(POS pos, java.lang.String lemma)
Description copied from class:DictionaryLook 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:
getIndexWordin classDictionary- Parameters:
pos- The part-of-speech.lemma- The orthographic representation of the word.- Returns:
- An IndexWord representing the word, or
nullif no such entry exists.
-
getIndexWordIterator
public java.util.Iterator getIndexWordIterator(POS pos, java.lang.String substring)
Description copied from class:DictionaryReturn an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.- Specified by:
getIndexWordIteratorin classDictionary- Parameters:
pos- The part-of-speech.- Returns:
- An iterator over
IndexWords.
-
getIndexWordIterator
public java.util.Iterator getIndexWordIterator(POS pos)
Description copied from class:DictionaryReturn an Iterator over all the IndexWords of part-of-speech pos in the database.- Specified by:
getIndexWordIteratorin classDictionary- Parameters:
pos- The part-of-speech- Returns:
- An iterator over
IndexWords
-
getRandomIndexWord
public IndexWord getRandomIndexWord(POS pos) throws JWNLException
- Specified by:
getRandomIndexWordin classDictionary- Throws:
JWNLException
-
getSynsetIterator
public java.util.Iterator getSynsetIterator(POS pos)
Description copied from class:DictionaryReturn an Iterator over all the Synsets of part-of-speech pos in the database.- Specified by:
getSynsetIteratorin classDictionary- Parameters:
pos- The part-of-speech.- Returns:
- An iterator over
Synsets.
-
getExceptionIterator
public java.util.Iterator getExceptionIterator(POS pos)
Description copied from class:DictionaryReturn an Iterator over all the Exceptions in the database.- Specified by:
getExceptionIteratorin classDictionary- Parameters:
pos- the part-of-speech- Returns:
- Iterator An iterator over
Strings
-
getIterator
private java.util.Iterator getIterator(java.util.Map map)
-
getSynsetAt
public Synset getSynsetAt(POS pos, long offset)
Description copied from class:DictionaryReturn theSynsetat offsetoffsetfrom the database.- Specified by:
getSynsetAtin 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
-
getException
public Exc getException(POS pos, java.lang.String derivation)
Description copied from class:DictionaryLookupderivationin the exceptions file of part-of-speechposand return an Exc object containing the results.- Specified by:
getExceptionin classDictionary- Parameters:
pos- the exception file to look inderivation- the word to look up- Returns:
- Exc the Exc object
-
close
public void close()
Description copied from class:DictionaryShut down the dictionary- Specified by:
closein classDictionary
-
loadDictFile
private java.util.Map loadDictFile(DictionaryFile file) throws JWNLException
- Throws:
JWNLException
-
putTable
private void putTable(POS pos, DictionaryFileType fileType, java.util.Map table)
Use table for lookups to the file represented by pos and fileType.
-
getTable
private java.util.Map getTable(POS pos, DictionaryFileType fileType)
-
getUsageCount
public int getUsageCount(long offset, java.lang.String lemma)Not implemented in Map yet.
-
getSenseKey
public java.lang.String getSenseKey(long offset, java.lang.String lemma)Not implemented in Map yet.
-
-