|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.mit.jwi.RAMDictionary
public class RAMDictionary
Default implementation of the IRAMDictionary interface. This
implementation is designed to wrap an arbitrary dictionary object; however,
convenience constructors are provided for the most common use cases (i.e.,
Wordnet located on the local filesystem, pointed to by a URL or File).
Note: If you receive an OutOfMemoryError while using this
object, try increasing the heap size of your JVM, for example, by using the
-Xmx switch.
| Nested Class Summary | |
|---|---|
static class |
RAMDictionary.DataLoader
A Callable that creates a dictionary data from a specified
dictionary. |
static class |
RAMDictionary.DictionaryData
Object that holds all the dictionary data loaded from the Wordnet files. |
protected class |
RAMDictionary.HotSwappableExceptionEntryIterator
A hot swappable iterator that iterates over exceptions entries for a particular part of speech. |
protected class |
RAMDictionary.HotSwappableIndexWordIterator
A hot swappable iterator for index words. |
protected class |
RAMDictionary.HotSwappableIterator<E>
An iterator that allows the dictionary to be loaded into memory while it is iterating. |
protected class |
RAMDictionary.HotSwappableSenseEntryIterator
A hot swappable iterator that iterates over sense entries. |
protected class |
RAMDictionary.HotSwappableSynsetIterator
A hot swappable iterator for synsets. |
protected class |
RAMDictionary.JWIBackgroundDataLoader
This runnable loads the dictionary data into memory and sets the appropriate variable in the parent dictionary. |
| Nested classes/interfaces inherited from interface edu.mit.jwi.data.IHasLifecycle |
|---|
IHasLifecycle.ObjectClosedException |
| Field Summary | |
|---|---|
protected IDictionary |
backing
|
protected RAMDictionary.DictionaryData |
data
|
protected Lock |
lifecycleLock
|
protected Thread |
loader
|
protected Lock |
loadLock
|
protected int |
loadPolicy
|
protected IVersion |
version
|
| Fields inherited from interface edu.mit.jwi.data.ILoadPolicy |
|---|
BACKGROUND_LOAD, IMMEDIATE_LOAD, NO_LOAD |
| Constructor Summary | |
|---|---|
RAMDictionary(File file,
int loadPolicy)
Constructs a new wrapper RAM dictionary that will load the contents the specified local Wordnet data, with the specified load policy |
|
RAMDictionary(IDictionary dict,
int loadPolicy)
Constructs a new wrapper RAM dictionary that will load the contents of the wrapped dictionary into memory, with the specified load policy |
|
RAMDictionary(URL url,
int loadPolicy)
Constructs a new wrapper RAM dictionary that will load the contents the specified local Wordnet data, with the specified load policy |
|
| Method Summary | |
|---|---|
void |
close()
This closes the object by disposing of data backing objects or connections. |
IDictionary |
getBackingDictionary()
Returns the dictionary that backs this instance. |
IExceptionEntry |
getExceptionEntry(IExceptionEntryID id)
Retrieves the exception entry for the specified id from the database. |
IExceptionEntry |
getExceptionEntry(String surfaceForm,
POS pos)
Retrieves the exception entry for the specified surface form and part of speech from the database. |
Iterator<IExceptionEntry> |
getExceptionEntryIterator(POS pos)
Returns an iterator that will iterate over all exception entries of the specified part of speech. |
IIndexWord |
getIndexWord(IIndexWordID id)
Retrieves the specified index word object from the database. |
IIndexWord |
getIndexWord(String lemma,
POS pos)
This method is identical to getIndexWord(IIndexWordID) and
is provided as a convenience. |
Iterator<IIndexWord> |
getIndexWordIterator(POS pos)
Returns an iterator that will iterate over all index words of the specified part of speech. |
int |
getLoadPolicy()
Returns the load policy for this object, expressed as an integer. |
ISenseEntry |
getSenseEntry(ISenseKey key)
Retrieves the sense entry for the specified sense key from the database. |
Iterator<ISenseEntry> |
getSenseEntryIterator()
Returns an iterator that will iterate over all sense entries in the dictionary. |
ISynset |
getSynset(ISynsetID id)
Retrieves the synset with the specified id from the database. |
Iterator<ISynset> |
getSynsetIterator(POS pos)
Returns an iterator that will iterate over all synsets of the specified part of speech. |
IVersion |
getVersion()
Returns the associated version for this object. |
IWord |
getWord(ISenseKey key)
Retrieves the word with the specified sense key from the database. |
IWord |
getWord(IWordID id)
Retrieves the word with the specified id from the database. |
boolean |
isLoaded()
Returns whether this object is loaded or not. |
boolean |
isOpen()
Returns true if the dictionary is open, that is, ready to
accept queries; returns false otherwise |
void |
load()
Starts a simple, non-blocking load. |
void |
load(boolean block)
Initiates the loading process. |
boolean |
open()
This opens the object by performing any required initialization steps. |
void |
setLoadPolicy(int policy)
Sets the load policy for this object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final IDictionary backing
protected final Lock lifecycleLock
protected final Lock loadLock
protected transient Thread loader
protected int loadPolicy
protected IVersion version
protected RAMDictionary.DictionaryData data
| Constructor Detail |
|---|
public RAMDictionary(IDictionary dict,
int loadPolicy)
dict - the dictionary to be wrappedloadPolicy - the load policy of the dictionary; see constants in
ILoadPolicy.ILoadPolicy
public RAMDictionary(URL url,
int loadPolicy)
url - a url pointing to a local copy of wordnet; may not be
nullloadPolicy - the load policy of the dictionary; see constants in
ILoadPolicy.
NullPointerException - if the specified url is nullILoadPolicy
public RAMDictionary(File file,
int loadPolicy)
file - a file pointing to a local copy of wordnet; may not be
nullloadPolicy - the load policy of the dictionary; see constants in
ILoadPolicy.
NullPointerException - if the specified file is nullILoadPolicy| Method Detail |
|---|
public IDictionary getBackingDictionary()
public int getLoadPolicy()
ILoadPolicy
getLoadPolicy in interface ILoadPolicypublic void setLoadPolicy(int policy)
ILoadPolicy
setLoadPolicy in interface ILoadPolicypolicy - the policy to implement; may be one of NO_LOAD,
BACKGROUND_LOAD, IMMEDIATE_LOAD or
an implementation-dependent value.public boolean isLoaded()
ILoadabletrue only if the loading process has completed and the
object is actually loaded; if the object is still in the process of
loading, or failed to load, the method should return false.
isLoaded in interface ILoadabletrue if the method has completed loading;
false otherwisepublic void load()
ILoadable
load in interface ILoadable
public void load(boolean block)
throws InterruptedException
ILoadableblock is false), or return
only when the loading process is complete. If the object is already
loaded, the method returns immediately and has no effect. If the object
is in the process of loading, and the method is called in blocking mode,
the method blocks until loading is complete, even if that call of the
method did not initiate the loading process. Some implementors of this
interface may not support the immediate-return functionality.
load in interface ILoadableblock - if true, the method returns only when the loading
process is complete; if false, the method returns
immediately.
InterruptedException - if the method is blocking, and is interrupted while waiting
for loading to complete
public boolean open()
throws IOException
IHasLifecyclefalse, then subsequent calls to
IHasLifecycle.isOpen() will return false.
open in interface IHasLifecycletrue if there were no errors in initialization;
false otherwise.
IOException - if there was IO error while performing initializataionpublic boolean isOpen()
IHasLifecycletrue if the dictionary is open, that is, ready to
accept queries; returns false otherwise
isOpen in interface IHasLifecycletrue if the object is open; false
otherwisepublic void close()
IClosable
close in interface IClosablepublic IVersion getVersion()
IHasVersionnull.
getVersion in interface IHasVersionnull if none.
public IIndexWord getIndexWord(String lemma,
POS pos)
IDictionarygetIndexWord(IIndexWordID) and
is provided as a convenience.
getIndexWord in interface IDictionarylemma - the lemma for the index word requested; may not be
null, empty, or all whitespacepos - the part of speech; may not be null
null if none is foundpublic IIndexWord getIndexWord(IIndexWordID id)
IDictionarynull.
Note: This call does no stemming on the specified lemma, it is
taken as specified. That is, if you submit the word "dogs", it will
search for "dogs", not "dog"; in the standard Wordnet distribution, there
is no entry for "dogs" and therefore the call will return
null. This is in contrast to the Wordnet API provided by
Princeton. If you want your searches to capture morphological variation,
use the descendants of the IStemmer class.
getIndexWord in interface IDictionaryid - the id of the index word to search for; may not be
null
null otherwisepublic Iterator<IIndexWord> getIndexWordIterator(POS pos)
IDictionary
getIndexWordIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
null
public IWord getWord(IWordID id)
IDictionarynull
getWord in interface IDictionaryid - the id of the word to search for; may not be null
null otherwisepublic IWord getWord(ISenseKey key)
IDictionarynull
getWord in interface IDictionarykey - the sense key of the word to search for; may not be
null
null otherwisepublic ISynset getSynset(ISynsetID id)
IDictionarynull
getSynset in interface IDictionaryid - the id of the synset to search for; may not be
null
null otherwisepublic Iterator<ISynset> getSynsetIterator(POS pos)
IDictionary
getSynsetIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
null
public ISenseEntry getSenseEntry(ISenseKey key)
IDictionarynull
getSenseEntry in interface IDictionarykey - the sense key of the entry to search for; may not be
null
null otherwisepublic Iterator<ISenseEntry> getSenseEntryIterator()
IDictionary
getSenseEntryIterator in interface IDictionary
public IExceptionEntry getExceptionEntry(String surfaceForm,
POS pos)
IDictionarynull
getExceptionEntry in interface IDictionarysurfaceForm - the surface form to be looked up; may not be null
, empty, or all whitespacepos - the part of speech; may not be null
null otherwisepublic IExceptionEntry getExceptionEntry(IExceptionEntryID id)
IDictionarynull
getExceptionEntry in interface IDictionaryid - the exception entry id of the entry to search for; may not be
null
public Iterator<IExceptionEntry> getExceptionEntryIterator(POS pos)
IDictionary
getExceptionEntryIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||