Java Access to WordNet

danbikel.wordnet
Class WordNetLocal

java.lang.Object
  |
  +--danbikel.wordnet.WordNetLocal
All Implemented Interfaces:
Remote, WordNetRemote

public class WordNetLocal
extends Object
implements WordNetRemote

Implementation of the WordNetRemote interface, allowing access to the WordNet database via RMI.


Field Summary
protected  WordNet wn
          WordNet object used to carry out remotely-requested method calls.
 
Fields inherited from interface danbikel.wordnet.WordNetRemote
adjPos, adjPosIdx, advPos, advPosIdx, maxPosIdx, minPosIdx, nounPos, nounPosIdx, numPartsOfSpeech, verbPos, verbPosIdx
 
Constructor Summary
WordNetLocal(WordNet wn)
          Constructs a new WordNetRMI object, using the passed WordNet object to carry out the remotely-requested WordNet method calls.
 
Method Summary
 boolean contains(String word, String pos)
          Returns whether a given word and part of speech exist in the database.
 boolean exists(String word, String pos)
          Returns whether a given word and part of speech exist in the database.
 int[][] getAllParentsBFS(String pos, int synset)
          Returns a breadth-first search of the hypernym subgraph of synset.
 int[] getAllSynsets(String word, String pos)
          Gets all synsets for word and pos.
 RemoteEnumeration getCachedDataEntries(int posIdx)
          Returns a RemoteEnumeraton to allow iteration over all cached data entries.
 RemoteEnumeration getCachedDataEntries(String pos)
          Returns a RemoteEnumeraton to allow iteration over all cached data entries.
 RemoteEnumeration getCachedIndexEntries(int posIdx)
          Returns an RemoteEnumeraton to allow iteration over all cached index entries.
 RemoteEnumeration getCachedIndexEntries(String pos)
          Returns an RemoteEnumeraton to allow iteration over all cached index entries.
 WNPointer[] getChildPointers(String pos, int synset)
          Gets the child (hyponym) pointers for the synset specified by pos and synset, as defined by pointers that pass through ChildSemanticPointerFilter.
 int[] getChildren(String pos, int synset)
          Gets all synsets that are children (hyponyms) of synset.
 WNDataEntry getDataEntry(String pos, int synset)
          Gets the WNDataEntry object for pos and synset.
 WNIndexEntry getIndexEntry(String word, String pos)
          Gets the WNIndexEntry for word and pos, printing errors if there is no such word-pos pair in the database.
 WNIndexEntry getIndexEntry(String word, String pos, boolean printErrors)
          Gets the WNIndexEntry for word and pos.
 WNPointer[] getParentPointers(String pos, int synset)
          Gets the parent (hypernym) pointers for the synset specified by pos and synset, as defined by pointers that pass through ParentSemanticPointerFilter.
 int[] getParents(String pos, int synset)
          Gets all synsets that are parents (hypernyms) of synset.
 int getSenseNum(String word, String pos, int synset)
          Gets the sense number for the passed synset of word and pos.
 int getSynset(String word, String pos, int senseNum)
          Gets the senseNumth synset for word and pos.
 WNWord getSynsetName(String pos, int synset)
          Gets the name of a synset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wn

protected WordNet wn
WordNet object used to carry out remotely-requested method calls. While we could have extended the WordNet class to implement WordNetRMI, that would have required re-implementing all of the methods that this class now inherits from UnicastRemoteObject. Therefore, this class acts as a flow-through to methods implemented by the WordNet class.

Constructor Detail

WordNetLocal

public WordNetLocal(WordNet wn)
             throws RemoteException
Constructs a new WordNetRMI object, using the passed WordNet object to carry out the remotely-requested WordNet method calls.

Method Detail

contains

public boolean contains(String word,
                        String pos)
                 throws RemoteException
Returns whether a given word and part of speech exist in the database.

Specified by:
contains in interface WordNetRemote
Parameters:
word - a lemma in WordNet.
pos - a WordNet part of speech.
RemoteException

exists

public boolean exists(String word,
                      String pos)
               throws RemoteException
Returns whether a given word and part of speech exist in the database. This method is a synonym for contains(java.lang.String, java.lang.String).

Specified by:
exists in interface WordNetRemote
Parameters:
word - a lemma in WordNet.
pos - a WordNet part of speech.
RemoteException

getIndexEntry

public WNIndexEntry getIndexEntry(String word,
                                  String pos)
                           throws RemoteException
Gets the WNIndexEntry for word and pos, printing errors if there is no such word-pos pair in the database.

Specified by:
getIndexEntry in interface WordNetRemote
Parameters:
word - a lemma in WordNet.
pos - a WordNet part of speech.
RemoteException

getIndexEntry

public WNIndexEntry getIndexEntry(String word,
                                  String pos,
                                  boolean printErrors)
                           throws RemoteException
Gets the WNIndexEntry for word and pos.

Specified by:
getIndexEntry in interface WordNetRemote
Parameters:
word - a lemma in WordNet.
pos - a WordNet part of speech.
printErrors - print errors using WordNet.printError(java.lang.String) if true.
RemoteException

getDataEntry

public WNDataEntry getDataEntry(String pos,
                                int synset)
                         throws RemoteException
Gets the WNDataEntry object for pos and synset.

Specified by:
getDataEntry in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a synset in WordNet.
RemoteException

getAllSynsets

public int[] getAllSynsets(String word,
                           String pos)
                    throws RemoteException
Gets all synsets for word and pos.

Specified by:
getAllSynsets in interface WordNetRemote
Parameters:
word - a lemma in WordNet.
pos - a WordNet part of speech.
RemoteException
See Also:
WNIndexEntry.getSynsets()

getSynset

public int getSynset(String word,
                     String pos,
                     int senseNum)
              throws RemoteException
Gets the senseNumth synset for word and pos. Note that this is the senseNum - 1st element in the array returned by getAllSynsets(java.lang.String, java.lang.String), as sense numbers are 1-indexed.

Specified by:
getSynset in interface WordNetRemote
RemoteException

getSenseNum

public int getSenseNum(String word,
                       String pos,
                       int synset)
                throws RemoteException
Gets the sense number for the passed synset of word and pos. N.B.: This method is O(n), where n is the number of synsets for word, pos.

Specified by:
getSenseNum in interface WordNetRemote
RemoteException

getParentPointers

public WNPointer[] getParentPointers(String pos,
                                     int synset)
                              throws RemoteException
Gets the parent (hypernym) pointers for the synset specified by pos and synset, as defined by pointers that pass through ParentSemanticPointerFilter.

Specified by:
getParentPointers in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a WordNet synset.
RemoteException

getParents

public int[] getParents(String pos,
                        int synset)
                 throws RemoteException
Gets all synsets that are parents (hypernyms) of synset. A cache is used for these parent-synset int arrays.

Specified by:
getParents in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a WordNet synset.
RemoteException

getChildPointers

public WNPointer[] getChildPointers(String pos,
                                    int synset)
                             throws RemoteException
Gets the child (hyponym) pointers for the synset specified by pos and synset, as defined by pointers that pass through ChildSemanticPointerFilter.

Specified by:
getChildPointers in interface WordNetRemote
Parameters:
pos - a WordNet part of speech
synset - a WordNet synset
RemoteException

getChildren

public int[] getChildren(String pos,
                         int synset)
                  throws RemoteException
Gets all synsets that are children (hyponyms) of synset. A cache is used for these child-synset int arrays.

Specified by:
getChildren in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a WordNet synset.
RemoteException

getSynsetName

public WNWord getSynsetName(String pos,
                            int synset)
                     throws RemoteException
Gets the name of a synset. A synset's name is defined to be the first lemma in the list of lemmas contained in the database.

Specified by:
getSynsetName in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a WordNet synset.
Returns:
the WNWord object that represents the first lemma in the list of lemmas for synset in the database.
RemoteException

getAllParentsBFS

public int[][] getAllParentsBFS(String pos,
                                int synset)
                         throws RemoteException
Returns a breadth-first search of the hypernym subgraph of synset.

Specified by:
getAllParentsBFS in interface WordNetRemote
Parameters:
pos - a WordNet part of speech.
synset - a WordNet synset.
Returns:
an array of int arrays, where the ith element contains all synsets that have a hyponym path of length i to synset. Thus, the first element is guaranteed to be an array of length 1 containing only synset. Furthermore, since adjectives and adverbs do not have hypernyms, the return value for these two parts of speech is always of length 1.
RemoteException

getCachedDataEntries

public RemoteEnumeration getCachedDataEntries(String pos)
                                       throws RemoteException
Returns a RemoteEnumeraton to allow iteration over all cached data entries. Note that RemoteEnumeration objects, like the Enumeration objects they wrap, are fail-fast, and are even more brittle in that a RemoteException could be raised at any time.

Specified by:
getCachedDataEntries in interface WordNetRemote
RemoteException

getCachedDataEntries

public RemoteEnumeration getCachedDataEntries(int posIdx)
                                       throws RemoteException
Returns a RemoteEnumeraton to allow iteration over all cached data entries. Note that RemoteEnumeration objects, like the Enumeration objects they wrap, are fail-fast, and are even more brittle in that a RemoteException could be raised at any time.

Specified by:
getCachedDataEntries in interface WordNetRemote
RemoteException

getCachedIndexEntries

public RemoteEnumeration getCachedIndexEntries(String pos)
                                        throws RemoteException
Returns an RemoteEnumeraton to allow iteration over all cached index entries. Note that RemoteEnumeration objects, like the Enumeration objects they wrap, are fail-fast, and are even more brittle in that a RemoteException could be raised at any time.

Specified by:
getCachedIndexEntries in interface WordNetRemote
RemoteException

getCachedIndexEntries

public RemoteEnumeration getCachedIndexEntries(int posIdx)
                                        throws RemoteException
Returns an RemoteEnumeraton to allow iteration over all cached index entries. Note that RemoteEnumeration objects, like the Enumeration objects they wrap, are fail-fast, and are even more brittle in that a RemoteException could be raised at any time.

Specified by:
getCachedIndexEntries in interface WordNetRemote
RemoteException

Java Access to WordNet

Author: Dan Bikel