|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.mit.jverbnet.util.AbstractHasLifecycle
edu.mit.jverbnet.index.VerbIndex
public class VerbIndex
Default implementation of the IVerbIndex interface.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface edu.mit.jverbnet.util.IHasLifecycle |
|---|
IHasLifecycle.ObjectClosedException |
| Constructor Summary | |
|---|---|
VerbIndex(java.io.File file)
Creates a new verb index that uses the data at the specified location. |
|
VerbIndex(java.net.URL url)
Creates a new verb index that uses the data at the specified location. |
|
| Method Summary | ||
|---|---|---|
protected
|
compressAndMakeUnmodifiable(java.util.Map<K,java.util.Set<V>> map)
Utility method for reallocating and making unmodifiable a map of sets. |
|
protected IVersion |
determineVersion()
Determines the version of verbnet, as best is able. |
|
protected void |
doClose()
Subclasses should put tear-down, closing code in this method. |
|
protected boolean |
doIsOpen()
Subclasses should put code that determines whether the object is open in here. |
|
protected boolean |
doOpen()
Subclasses should put initialization code in this method. |
|
java.util.Set<IMember> |
getMembers(IWordnetKey key)
Returns all members in the index with the specified wordnet key. |
|
java.util.Set<IMember> |
getMembers(java.lang.String grouping)
Returns all members in the index with the specified grouping. |
|
IVerbClass |
getRootVerb(java.lang.String id)
Returns the root verb class with the specified id, or null if no
such verb class can be found in the index. |
|
protected
|
getSetForKey(java.util.Map<K,java.util.Set<V>> map,
K key)
Utility method for filling in a map of keys to sets. |
|
IVerbClass |
getVerb(java.lang.String id)
Returns the verb class with the specified id, or null if no
such verb class can be found in the index. |
|
IVersion |
getVersion()
The version of the index. |
|
protected java.util.Map<java.lang.String,IVerbClass> |
initVerbByIdMap()
Initialization code for reading the verbnet XML. |
|
java.util.Iterator<IVerbClass> |
iterator()
Returns an iterator over all verb classes in the index, in the order they are encountered in the data files. |
|
java.util.Iterator<java.lang.String> |
iteratorGroups()
Returns an iterator over all groupings in the index, in their natural order. |
|
java.util.Iterator<IVerbClass> |
iteratorRoots()
Returns an iterator over all root verb classes in the index, in the order they are encountered in the data files. |
|
java.util.Iterator<IWordnetKey> |
iteratorWordnetKeys()
Returns an iterator over all wordnet keys in the index, in their natural order. |
|
protected boolean |
parse(org.xml.sax.XMLReader parser,
java.io.InputStream in,
java.lang.String filename)
Parses an XML input stream. |
|
void |
setErrorHandler(org.xml.sax.ErrorHandler eh)
Sets the XML error handler that will be used by the index when parsing XML files. |
|
void |
setVersion(IVersion newVersion)
Sets the version for this index. |
|
| Methods inherited from class edu.mit.jverbnet.util.AbstractHasLifecycle |
|---|
checkOpen, close, isOpen, open |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface edu.mit.jverbnet.util.IHasLifecycle |
|---|
close, isOpen, open |
| Constructor Detail |
|---|
public VerbIndex(java.io.File file)
file - the file or directory containing the verbnet datapublic VerbIndex(java.net.URL url)
url - the file or directory containing the verbnet data| Method Detail |
|---|
public IVersion getVersion()
IVerbIndexIVersion.UNKNOWN. If the version has not yet been
determined, and the implementation does not determine the version
automatically when called (e.g., the implementation requires a call to
IVerbIndex.setVersion(IVersion)) the method will throw an exception.
getVersion in interface IVerbIndexIVersion.UNKNOWNpublic void setVersion(IVersion newVersion)
IVerbIndex
setVersion in interface IVerbIndexnewVersion - the version to use for this index; may not be
nullprotected IVersion determineVersion()
IVersion.UNKNOWN.
IVersion.UNKNOWN
protected boolean doOpen()
throws java.io.IOException
AbstractHasLifecyclefalse or throw an exception. The abstract
lifecycle object takes care of calling the AbstractHasLifecycle.doClose() method if
initialization fails.
doOpen in class AbstractHasLifecycletrue if initialization succeeds; false
otherwise
java.io.IOException - if there is an IO error while initializingpublic void setErrorHandler(org.xml.sax.ErrorHandler eh)
eh - the error handler to be used; may be null
protected java.util.Map<java.lang.String,IVerbClass> initVerbByIdMap()
throws java.io.IOException
java.io.IOException - if there is an IO error
protected boolean parse(org.xml.sax.XMLReader parser,
java.io.InputStream in,
java.lang.String filename)
throws java.io.IOException
parser - the parser to use; may not be nullin - the input stream from which to read the data
true if the parse failed and the initialization
should halt; false otherwise
java.io.IOException - if there is an IO error when parsing
{@link - NullPointerException} if the parser or input stream are
null
protected <K,V> java.util.Set<V> getSetForKey(java.util.Map<K,java.util.Set<V>> map,
K key)
map - the map to query for the set indexed by the keykey - the key under which to look for the set
nullprotected <K,V> java.util.Map<K,java.util.Set<V>> compressAndMakeUnmodifiable(java.util.Map<K,java.util.Set<V>> map)
map - the map whose set values should be reallocated and made
unmodifiable; the map itself is made unmodifiable
protected boolean doIsOpen()
AbstractHasLifecycletrue if the object is open; false
otherwise.
doIsOpen in class AbstractHasLifecycletrue if the object is open; false
otherwise.protected void doClose()
AbstractHasLifecycleAbstractHasLifecycle.open() the
object.
doClose in class AbstractHasLifecyclepublic IVerbClass getVerb(java.lang.String id)
IVerbIndexnull if no
such verb class can be found in the index. Ids are usually of the form
'verb-##.#', e.g., 'accompany-51.7'.
getVerb in interface IVerbIndexid - the id of the class
null if nonepublic IVerbClass getRootVerb(java.lang.String id)
IVerbIndexnull if no
such verb class can be found in the index. Ids are usually of the form
'verb-##.#', e.g., 'accompany-51.7'.
getRootVerb in interface IVerbIndexid - the id of the class
null if nonepublic java.util.Set<IMember> getMembers(IWordnetKey key)
IVerbIndexnull key indicates all members that have no key specified.
getMembers in interface IVerbIndexkey - the key for which members should be retrieved; may be
null
nullpublic java.util.Set<IMember> getMembers(java.lang.String grouping)
IVerbIndexnull, empty, or all whitespace grouping indicates all
members that have no grouping specified.
getMembers in interface IVerbIndexgrouping - the grouping for which members should be retrieved; may be
null, empty, or all whitespace.
nullpublic java.util.Iterator<IVerbClass> iterator()
IVerbIndex
iterator in interface IVerbIndexiterator in interface java.lang.Iterable<IVerbClass>public java.util.Iterator<IVerbClass> iteratorRoots()
IVerbIndex
iteratorRoots in interface IVerbIndexpublic java.util.Iterator<IWordnetKey> iteratorWordnetKeys()
IVerbIndex
iteratorWordnetKeys in interface IVerbIndexpublic java.util.Iterator<java.lang.String> iteratorGroups()
IVerbIndex
iteratorGroups in interface IVerbIndex
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||