Package net.didion.jwnl.dictionary
Class Dictionary
java.lang.Object
net.didion.jwnl.dictionary.Dictionary
- All Implemented Interfaces:
Installable
- Direct Known Subclasses:
AbstractCachingDictionary
,MapBackedDictionary
Abstract representation of a WordNet dictionary.
See the architecture documentation for information on subclassing Dictionary.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static Dictionary
The singleton instance of the dictionary to be used throughout the system.private static final MessageLog
private MorphologicalProcessor
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Create a Dictionary that does not do morphological processing.protected
Dictionary
(MorphologicalProcessor morph) Create a Dictionary using the specified MorphologicalProcessor. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Shut down the dictionaryabstract Exc
getException
(POS pos, String derivation) Lookupderivation
in the exceptions file of part-of-speechpos
and return an Exc object containing the results.abstract Iterator
getExceptionIterator
(POS pos) Return an Iterator over all the Exceptions in the database.abstract IndexWord
getIndexWord
(POS pos, String lemma) Look up a word in the database.abstract Iterator
getIndexWordIterator
(POS pos) Return an Iterator over all the IndexWords of part-of-speech pos in the database.abstract Iterator
getIndexWordIterator
(POS pos, String substring) Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.static Dictionary
abstract IndexWord
getRandomIndexWord
(POS pos) abstract Synset
getSynsetAt
(POS pos, long offset) Return theSynset
at offsetoffset
from the database.abstract Iterator
getSynsetIterator
(POS pos) Return an Iterator over all the Synsets of part-of-speech pos in the database.lookupAllIndexWords
(String lemma) Return a set ofIndexWord
s, with each element in the set corresponding to a part-of-speech of word.lookupIndexWord
(POS pos, String lemma) Main word lookup procedure.protected static String
prepareQueryString
(String lemma) Prepares the lemma for being used in a lookup operation.protected static void
setDictionary
(Dictionary dictionary) static void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.didion.jwnl.util.factory.Installable
install
-
Field Details
-
_log
-
_dictionary
The singleton instance of the dictionary to be used throughout the system. -
_morph
-
-
Constructor Details
-
Dictionary
protected Dictionary()Create a Dictionary that does not do morphological processing. -
Dictionary
Create a Dictionary using the specified MorphologicalProcessor.
-
-
Method Details
-
getInstance
-
setDictionary
-
uninstall
public static void uninstall() -
prepareQueryString
Prepares the lemma for being used in a lookup operation. Specifically, this method trims whitespace and converts the lemma to lower case.- Parameters:
lemma
- the lemma to be prepared- Returns:
- String the prepared lemma
-
getIndexWordIterator
Return an Iterator over all the IndexWords of part-of-speech pos in the database.- Parameters:
pos
- The part-of-speech- Returns:
- An iterator over
IndexWord
s - Throws:
JWNLException
-
getIndexWordIterator
Return an Iterator over all the IndexWords of part-of-speech pos whose lemmas contain substring as a substring.- Parameters:
pos
- The part-of-speech.- Returns:
- An iterator over
IndexWord
s. - Throws:
JWNLException
-
getIndexWord
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, uselookupIndexWord(POS, String)
.- 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
- Throws:
JWNLException
-
getSynsetIterator
Return an Iterator over all the Synsets of part-of-speech pos in the database.- Parameters:
pos
- The part-of-speech.- Returns:
- An iterator over
Synset
s. - Throws:
JWNLException
-
getSynsetAt
Return theSynset
at offsetoffset
from the database.- 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
-
getExceptionIterator
Return an Iterator over all the Exceptions in the database.- Parameters:
pos
- the part-of-speech- Returns:
- Iterator An iterator over
String
s - Throws:
JWNLException
-
getException
Lookupderivation
in the exceptions file of part-of-speechpos
and return an Exc object containing the results.- Parameters:
pos
- the exception file to look inderivation
- the word to look up- Returns:
- Exc the Exc object
- Throws:
JWNLException
-
close
public abstract void close()Shut down the dictionary -
getMorphologicalProcessor
-
lookupIndexWord
Main word lookup procedure. First try a normal lookup. If that doesn't work, try looking up the stemmed form of the lemma.- Parameters:
pos
- the part-of-speech of the word to look uplemma
- the lemma to look up- Returns:
- IndexWord the IndexWord found by the lookup procedure, or null if an IndexWord is not found
- Throws:
JWNLException
-
lookupAllIndexWords
Return a set ofIndexWord
s, with each element in the set corresponding to a part-of-speech of word.- Parameters:
lemma
- the word for which to lookup senses- Returns:
- An array of IndexWords, each of which is a sense of word
- Throws:
JWNLException
-