public class DataSourceDictionary extends Object implements IDataSourceDictionary
IDictionary interface. A path to the
Wordnet dictionary files must be provided. If no IDataProvider is
specified, it uses the default implementation provided with the distribution.| Modifier and Type | Class and Description |
|---|---|
class |
DataSourceDictionary.DataFileIterator
Iterates over data files.
|
class |
DataSourceDictionary.ExceptionFileIterator
Iterates over exception files.
|
class |
DataSourceDictionary.FileIterator<T,N>
Abstract class used for iterating over line-based files.
|
class |
DataSourceDictionary.FileIterator2<T>
A file iterator where the data type returned by the iterator is the same
as that returned by the backing data source.
|
class |
DataSourceDictionary.IndexFileIterator
Iterates over index files.
|
class |
DataSourceDictionary.SenseEntryFileIterator
Iterates over the sense file.
|
IHasLifecycle.LifecycleState, IHasLifecycle.ObjectClosedException, IHasLifecycle.ObjectOpenException| Constructor and Description |
|---|
DataSourceDictionary(IDataProvider provider)
Constructs a dictionary with a caller-specified
IDataProvider. |
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkOpen()
An internal method for assuring compliance with the dictionary interface
that says that methods will throw
ObjectClosedExceptions if
the dictionary has not yet been opened. |
void |
close()
This closes the object by disposing of data backing objects or
connections.
|
Charset |
getCharset()
Returns the character set associated with this object.
|
IDataProvider |
getDataProvider()
Returns the data provider for this dictionary.
|
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.
|
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 |
isOpen()
Returns
true if the dictionary is open, that is, ready to
accept queries; returns false otherwise |
boolean |
open()
This opens the object by performing any required initialization steps.
|
void |
setCharset(Charset charset)
Sets the character set associated with this dictionary.
|
protected void |
setHeadWord(ISynset synset)
This method sets the head word on the specified synset by searching in
the dictionary to find the head of its cluster.
|
public DataSourceDictionary(IDataProvider provider)
IDataProvider.NullPointerException - if the specified data provider is nullpublic IDataProvider getDataProvider()
IDataSourceDictionarynull.getDataProvider in interface IDataSourceDictionarypublic IVersion getVersion()
IHasVersionnull.getVersion in interface IHasVersionnull if none.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 void close()
IClosablepublic boolean isOpen()
IHasLifecycletrue if the dictionary is open, that is, ready to
accept queries; returns false otherwiseisOpen in interface IHasLifecycletrue if the object is open; false
otherwiseprotected void checkOpen()
ObjectClosedExceptions if
the dictionary has not yet been opened.ObjectClosedException - if the dictionary is closed.public Charset getCharset()
IHasCharsetnull.getCharset in interface IHasCharsetnullpublic void setCharset(Charset charset)
IDictionarynull.setCharset in interface IDictionarycharset - the possibly null character set to use when
decoding files.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 nullnull 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
nullnull otherwisepublic IWord getWord(IWordID id)
IDictionarynullgetWord in interface IDictionaryid - the id of the word to search for; may not be nullnull otherwisepublic IWord getWord(ISenseKey key)
IDictionarynullgetWord in interface IDictionarykey - the sense key of the word to search for; may not be
nullnull otherwisepublic ISenseEntry getSenseEntry(ISenseKey key)
IDictionarynullgetSenseEntry in interface IDictionarykey - the sense key of the entry to search for; may not be
nullnull otherwisepublic ISynset getSynset(ISynsetID id)
IDictionarynullgetSynset in interface IDictionaryid - the id of the synset to search for; may not be
nullnull otherwiseprotected void setHeadWord(ISynset synset)
public IExceptionEntry getExceptionEntry(String surfaceForm, POS pos)
IDictionarynullgetExceptionEntry 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 nullnull otherwisepublic IExceptionEntry getExceptionEntry(IExceptionEntryID id)
IDictionarynullgetExceptionEntry in interface IDictionaryid - the exception entry id of the entry to search for; may not be
nullpublic Iterator<IIndexWord> getIndexWordIterator(POS pos)
IDictionarygetIndexWordIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
nullpublic Iterator<ISynset> getSynsetIterator(POS pos)
IDictionarygetSynsetIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
nullpublic Iterator<IExceptionEntry> getExceptionEntryIterator(POS pos)
IDictionarygetExceptionEntryIterator in interface IDictionarypos - the part of speech over which to iterate; may not be
nullpublic Iterator<ISenseEntry> getSenseEntryIterator()
IDictionarygetSenseEntryIterator in interface IDictionaryCopyright © 2018. All rights reserved.