public abstract class Dictionary
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
Dictionary.Version
Represents a version of WordNet.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHECK_LEX_IDS_KEY
Parameter name: whether to check and fix lexicographer ids, default true.
|
static java.lang.String |
DEFAULT_RESOURCE_CONFIG_PATH
Default name of the configuration file for resource instance creation.
|
static java.lang.String |
DICTIONARY_ELEMENT_FACTORY
The class of DictionaryElementFactory to use.
|
static java.lang.String |
EDIT_CHECK_ALIEN_POINTERS
Parameter name: whether to check for alien pointers (pointing nowhere, or to another dictionary), default true.
|
static java.lang.String |
EDIT_MANAGE_SYMMETRIC_POINTERS
Parameter name: whether to add symmetric pointers automatically, default true.
|
protected DictionaryElementFactory |
elementFactory |
static java.lang.String |
MORPHOLOGICAL_PROCESSOR
Parameter name: class of the morphological processor to use.
|
protected java.util.Map<java.lang.String,Param> |
params |
Modifier | Constructor and Description |
---|---|
protected |
Dictionary(org.w3c.dom.Document doc) |
Modifier and Type | Method and Description |
---|---|
void |
addElement(DictionaryElement element)
Adds dictionary element to the dictionary.
|
void |
addException(Exc exc)
Adds exception to the dictionary.
|
void |
addIndexWord(IndexWord indexWord)
Adds index word to the dictionary.
|
void |
addSynset(Synset synset)
Adds synset to the dictionary.
|
protected void |
checkEditable()
Checks whether dictionary is editable and throws if not;
|
abstract void |
close()
Shuts down the dictionary, freeing resources.
|
Exc |
createException(POS pos,
java.lang.String lemma,
java.util.List<java.lang.String> exceptions)
Creates an exception in the dictionary.
|
IndexWord |
createIndexWord(POS pos,
java.lang.String lemma,
Synset synset)
Creates index word.
|
Synset |
createSynset(POS pos)
Creates synset of the specified part of speech.
|
boolean |
delete()
Deletes dictionary files.
|
void |
edit()
Puts the dictionary into edit mode.
|
boolean |
getCheckAlienPointers() |
static Dictionary |
getDatabaseBackedInstance(java.lang.String dbURL)
Returns DatabaseBackedDictionary instance with default configuration.
|
static Dictionary |
getDefaultResourceInstance()
Returns Dictionary instance configured from classpath by default.
|
abstract Exc |
getException(POS pos,
java.lang.String derivation)
Looks up derivation in the exceptions file of part-of-speech
pos and return an Exc object containing the results.
|
abstract java.util.Iterator<Exc> |
getExceptionIterator(POS pos)
Returns an iterator over all the exceptions.
|
static Dictionary |
getFileBackedInstance(java.lang.String dictionaryPath)
Returns FileBackedDictionary instance with default configuration.
|
java.lang.String[] |
getFrames(java.util.BitSet bits)
Returns the frames at the indexes encoded in l.
|
static java.lang.String[] |
getFrames(java.util.BitSet bits,
java.lang.String[] verbFrames)
Returns the frames at the indexes encoded in l.
|
abstract IndexWord |
getIndexWord(POS pos,
java.lang.String lemma)
Looks up a word.
|
abstract java.util.Iterator<IndexWord> |
getIndexWordIterator(POS pos)
Returns an Iterator over all the IndexWords of part-of-speech pos.
|
abstract java.util.Iterator<IndexWord> |
getIndexWordIterator(POS pos,
java.lang.String substring)
Returns an Iterator over all the IndexWords of part-of-speech pos
whose lemmas contain substring as a substring.
|
static Dictionary |
getInstance(org.xml.sax.InputSource properties)
Parses properties and creates a dictionary.
|
static Dictionary |
getInstance(java.io.InputStream properties)
Parses a properties file and creates a dictionary.
|
boolean |
getManageSymmetricPointers() |
static Dictionary |
getMapBackedInstance(java.lang.String dictionaryPath)
Returns MapBackedDictionary instance with default configuration.
|
ResourceBundleSet |
getMessages() |
MorphologicalProcessor |
getMorphologicalProcessor() |
java.util.Random |
getRandom() |
abstract IndexWord |
getRandomIndexWord(POS pos)
Returns a random index word of a specified pos.
|
static Dictionary |
getResourceInstance(java.lang.String propertiesPath)
Returns Dictionary instance configured from classpath.
|
static Dictionary |
getRestoreDictionary() |
abstract Synset |
getSynsetAt(POS pos,
long offset)
Returns the
Synset at offset offset. |
abstract java.util.Iterator<Synset> |
getSynsetIterator(POS pos)
Returns an iterator over all the synsets of part-of-speech pos.
|
static int[] |
getVerbFrameIndices(java.util.BitSet bits)
Returns the verb frame indices for a synset.
|
Dictionary.Version |
getVersion()
Returns the current dictionary version.
|
Word |
getWordBySenseKey(java.lang.String senseKey)
Returns a word by specified senseKey or null if not found.
|
boolean |
isEditable()
Returns whether the dictionary is editable.
|
IndexWordSet |
lookupAllIndexWords(java.lang.String lemma)
Returns a set of
IndexWord s, with each element in the set
corresponding to a part-of-speech of word. |
IndexWord |
lookupIndexWord(POS pos,
java.lang.String lemma)
Looks up a word lemma.
|
protected static java.lang.String |
prepareQueryString(java.lang.String lemma)
Prepares the lemma for being used in a lookup operation.
|
void |
removeElement(DictionaryElement element)
Removes the dictionary element from the dictionary.
|
void |
removeException(Exc exc)
Removes the exc from the dictionary.
|
void |
removeIndexWord(IndexWord indexWord)
Removes indexWord from the dictionary.
|
void |
removeSynset(Synset synset)
Removes synset from the dictionary.
|
protected void |
resolveAllPointers()
Loads all targets in load all pointers and all synsets in all index words.
|
protected void |
resolvePointers(POS pos) |
void |
save()
Saves the dictionary.
|
void |
setRandom(java.util.Random rand) |
static void |
setRestoreDictionary(Dictionary dictionary) |
public static final java.lang.String MORPHOLOGICAL_PROCESSOR
public static final java.lang.String EDIT_MANAGE_SYMMETRIC_POINTERS
public static final java.lang.String EDIT_CHECK_ALIEN_POINTERS
public static final java.lang.String CHECK_LEX_IDS_KEY
protected final java.util.Map<java.lang.String,Param> params
public static final java.lang.String DEFAULT_RESOURCE_CONFIG_PATH
public static final java.lang.String DICTIONARY_ELEMENT_FACTORY
protected final DictionaryElementFactory elementFactory
protected Dictionary(org.w3c.dom.Document doc) throws JWNLException
JWNLException
public static Dictionary getInstance(java.io.InputStream properties) throws JWNLException
properties
- the properties file streamJWNLException
- various JWNL exceptions, depending on where this failspublic static Dictionary getInstance(org.xml.sax.InputSource properties) throws JWNLException
properties
- input source with propertiesJWNLException
- various JWNL exceptions, depending on where this failspublic static Dictionary getFileBackedInstance(java.lang.String dictionaryPath) throws JWNLException
dictionaryPath
- dictionary pathJWNLException
- JWNLExceptionpublic static Dictionary getMapBackedInstance(java.lang.String dictionaryPath) throws JWNLException
dictionaryPath
- dictionary pathJWNLException
- JWNLExceptionpublic static Dictionary getDatabaseBackedInstance(java.lang.String dbURL) throws JWNLException
dbURL
- database urlJWNLException
- JWNLExceptionpublic static Dictionary getDefaultResourceInstance() throws JWNLException
JWNLException
- JWNLExceptionpublic static Dictionary getResourceInstance(java.lang.String propertiesPath) throws JWNLException
propertiesPath
- path to properties, for example "/net/sf/extjwnl/data/wordnet/wn31/res_properties.xml"JWNLException
- JWNLExceptionpublic static void setRestoreDictionary(Dictionary dictionary)
public static Dictionary getRestoreDictionary()
public abstract java.util.Iterator<IndexWord> getIndexWordIterator(POS pos) throws JWNLException
pos
- The part-of-speechIndexWord
sJWNLException
- JWNLExceptionpublic abstract java.util.Iterator<IndexWord> getIndexWordIterator(POS pos, java.lang.String substring) throws JWNLException
pos
- The part-of-speech.substring
- substringIndexWord
s.JWNLException
- JWNLExceptionpublic abstract IndexWord getIndexWord(POS pos, java.lang.String lemma) throws JWNLException
lookupIndexWord(POS, String)
.pos
- The part-of-speechlemma
- The orthographic representation of the wordnull
if
no such entry existsJWNLException
- JWNLExceptionpublic abstract IndexWord getRandomIndexWord(POS pos) throws JWNLException
pos
- part of speechJWNLException
- JWNLExceptionpublic abstract java.util.Iterator<Synset> getSynsetIterator(POS pos) throws JWNLException
pos
- The part-of-speech.Synset
s.JWNLException
- JWNLExceptionpublic abstract Synset getSynsetAt(POS pos, long offset) throws JWNLException
Synset
at offset offset.pos
- The part-of-speech file to look inoffset
- The offset of the synset in the fileJWNLException
- JWNLExceptionpublic abstract java.util.Iterator<Exc> getExceptionIterator(POS pos) throws JWNLException
pos
- the part-of-speechExc
sJWNLException
- JWNLExceptionpublic abstract Exc getException(POS pos, java.lang.String derivation) throws JWNLException
pos
- the exception file to look inderivation
- the word to look upJWNLException
- JWNLExceptionpublic abstract void close() throws JWNLException
JWNLException
- JWNLExceptionpublic ResourceBundleSet getMessages()
public MorphologicalProcessor getMorphologicalProcessor()
public Word getWordBySenseKey(java.lang.String senseKey) throws JWNLException
senseKey
- sense keyJWNLException
- JWNLExceptionpublic IndexWord lookupIndexWord(POS pos, java.lang.String lemma) throws JWNLException
pos
- the part-of-speech of the word to look uplemma
- the lemma to look upJWNLException
- JWNLExceptionpublic IndexWordSet lookupAllIndexWords(java.lang.String lemma) throws JWNLException
IndexWord
s, with each element in the set
corresponding to a part-of-speech of word.lemma
- the word for which to lookup sensesJWNLException
- JWNLExceptionpublic Dictionary.Version getVersion()
public boolean isEditable()
public void edit() throws JWNLException
JWNLException
- JWNLExceptionpublic void save() throws JWNLException
JWNLException
- JWNLExceptionpublic boolean delete() throws JWNLException
JWNLException
- JWNLExceptionpublic void addElement(DictionaryElement element) throws JWNLException
element
- element to addJWNLException
- JWNLExceptionpublic void removeElement(DictionaryElement element) throws JWNLException
element
- element to be removedJWNLException
- JWNLExceptionpublic Exc createException(POS pos, java.lang.String lemma, java.util.List<java.lang.String> exceptions) throws JWNLException
pos
- exception part of speechlemma
- exception lemmaexceptions
- list of base formsJWNLException
- JWNLExceptionpublic void addException(Exc exc) throws JWNLException
exc
- exception to addJWNLException
- JWNLExceptionpublic void removeException(Exc exc) throws JWNLException
exc
- exc to be removedJWNLException
- JWNLExceptionpublic Synset createSynset(POS pos) throws JWNLException
pos
- part of speechJWNLException
- JWNLExceptionpublic void addSynset(Synset synset) throws JWNLException
synset
- synset to addJWNLException
- JWNLExceptionpublic void removeSynset(Synset synset) throws JWNLException
synset
- synset to removeJWNLException
- JWNLExceptionpublic IndexWord createIndexWord(POS pos, java.lang.String lemma, Synset synset) throws JWNLException
pos
- part of speechlemma
- lemmasynset
- synsetJWNLException
- JWNLExceptionpublic void addIndexWord(IndexWord indexWord) throws JWNLException
indexWord
- index word to addJWNLException
- JWNLExceptionpublic void removeIndexWord(IndexWord indexWord) throws JWNLException
indexWord
- index word to removeJWNLException
- JWNLExceptionpublic boolean getManageSymmetricPointers()
public boolean getCheckAlienPointers()
public java.lang.String[] getFrames(java.util.BitSet bits)
Word
s as a long. Each bit represents
the frame at its corresponding index. If the bit is set, that verb
frame is valid for the word.bits
- frame flagspublic static java.lang.String[] getFrames(java.util.BitSet bits, java.lang.String[] verbFrames)
Word
s as a long. Each bit represents
the frame at its corresponding index. If the bit is set, that verb
frame is valid for the word.bits
- frame flagsverbFrames
- framespublic static int[] getVerbFrameIndices(java.util.BitSet bits)
bits
- the bit setpublic java.util.Random getRandom()
public void setRandom(java.util.Random rand)
protected static java.lang.String prepareQueryString(java.lang.String lemma)
lemma
- the lemma to be preparedprotected void checkEditable() throws JWNLException
JWNLException
- JWNLExceptionprotected void resolveAllPointers() throws JWNLException
JWNLException
- JWNLExceptionprotected void resolvePointers(POS pos) throws JWNLException
JWNLException