edu.mit.jwi.item
Class Synset

java.lang.Object
  extended by edu.mit.jwi.item.Synset
All Implemented Interfaces:
IHasPOS, IItem<ISynsetID>, ISynset, java.io.Serializable

public class Synset
extends java.lang.Object
implements ISynset

Default implementation of the ISynset interface.

Since:
JWI 1.0
Version:
2.4.0
Author:
Mark A. Finlayson
See Also:
Serialized Form

Nested Class Summary
static interface Synset.IWordBuilder
          A word builder used to construct word objects inside of the synset object constructor.
static class Synset.WordBuilder
          Holds information about word objects before they are instantiated.
 
Constructor Summary
Synset(ISynsetID id, ILexFile lexFile, boolean isAdjSat, boolean isAdjHead, java.lang.String gloss, java.util.List<Synset.IWordBuilder> wordBuilders, java.util.Map<IPointer,? extends java.util.List<ISynsetID>> ids)
          Constructs a new synset object with the specified parameters.
 
Method Summary
static int checkOffset(int offset)
          Throws an exception if the specified offset is not in the valid range of [0,99999999].
 boolean equals(java.lang.Object obj)
           
 java.lang.String getGloss()
          Returns the gloss (brief, plain-English description) of this synset.
 ISynsetID getID()
          Returns the ID object for this item.
 ILexFile getLexicalFile()
          Returns a description of the lexical file.
 int getOffset()
          Returns the data file byte offset of this synset.
 POS getPOS()
          Returns the associated part of speech for this object.
 java.util.Map<IPointer,java.util.List<ISynsetID>> getRelatedMap()
          Returns an immutable map from semantic pointers to immutable lists of synsets.
 java.util.List<ISynsetID> getRelatedSynsets()
          Returns an immutable list of synset ids for all synsets that are connected by pointers to this synset.
 java.util.List<ISynsetID> getRelatedSynsets(IPointer type)
          Returns an immutable list of the ids of all synsets that are related to this synset by the specified pointer type.
 int getType()
          Returns the type of the synset, encoded as follows: 1=Noun, 2=Verb, 3=Adjective, 4=Adverb, 5=Adjective Satellite.
 IWord getWord(int wordNumber)
          Returns the word with the specified word number.
 java.util.List<IWord> getWords()
          Returns an immutable list of the word objects (synset, index word pairs) associated with this synset.
 int hashCode()
           
 boolean isAdjectiveHead()
          Returns true if this synset is an adjective head; false otherwise.
 boolean isAdjectiveSatellite()
          Returns true if this synset is an adjective satellite; false otherwise.
static boolean isLegalOffset(int offset)
          Returns true an exception if the specified offset is not in the valid range of [0,99999999].
 java.lang.String toString()
           
static java.lang.String zeroFillOffset(int offset)
          Takes an integer in the closed range [0,99999999] and converts it into an eight decimal digit zero-filled string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Synset

public Synset(ISynsetID id,
              ILexFile lexFile,
              boolean isAdjSat,
              boolean isAdjHead,
              java.lang.String gloss,
              java.util.List<Synset.IWordBuilder> wordBuilders,
              java.util.Map<IPointer,? extends java.util.List<ISynsetID>> ids)
Constructs a new synset object with the specified parameters.

Parameters:
id - the synset id; may not be null
lexFile - the lexical file for this synset; may not be null
isAdjSat - true if this object represents an adjective satellite synset; false otherwise
isAdjHead - true if this object represents an adjective head synset; false otherwise
gloss - the gloss for this synset; may not be null
wordBuilders - the list of word builders for this synset; may not be null
ids - a map of related synset lists, indexed by pointer; may be null
Throws:
java.lang.NullPointerException - if any of the id, lexical file, word list, or gloss are null, or the word list contains a null
java.lang.IllegalArgumentException - if the word list is empty, or both the adjective satellite and adjective head flags are set
java.lang.IllegalArgumentException - if either the adjective satellite and adjective head flags are set, and the lexical file number is not zero
Since:
JWI 1.0
Method Detail

getID

public ISynsetID getID()
Description copied from interface: IItem
Returns the ID object for this item. Will not return null.

Specified by:
getID in interface IItem<ISynsetID>
Returns:
the non-null ID for this item

getOffset

public int getOffset()
Description copied from interface: ISynset
Returns the data file byte offset of this synset.

Specified by:
getOffset in interface ISynset
Returns:
int the offset in the associated data source

getPOS

public POS getPOS()
Description copied from interface: IHasPOS
Returns the associated part of speech for this object. If this object is not associated with any particular part of speech, this method may return null.

Specified by:
getPOS in interface IHasPOS
Returns:
The associated part of speech, or null if none.

getType

public int getType()
Description copied from interface: ISynset
Returns the type of the synset, encoded as follows: 1=Noun, 2=Verb, 3=Adjective, 4=Adverb, 5=Adjective Satellite.

Specified by:
getType in interface ISynset
Returns:
the type of the synset, an integer between 1 and 5, inclusive

getGloss

public java.lang.String getGloss()
Description copied from interface: ISynset
Returns the gloss (brief, plain-English description) of this synset.

Specified by:
getGloss in interface ISynset
Returns:
String Returns the non-null, non-empty gloss.

getWords

public java.util.List<IWord> getWords()
Description copied from interface: ISynset
Returns an immutable list of the word objects (synset, index word pairs) associated with this synset.

Specified by:
getWords in interface ISynset
Returns:
a non-null, immutable list of words for this synset

getWord

public IWord getWord(int wordNumber)
Description copied from interface: ISynset
Returns the word with the specified word number. Words are numbered sequentially from 1 up to, and including, 255.

Specified by:
getWord in interface ISynset
Parameters:
wordNumber - the number of the word to be retrieved
Returns:
the word with the specified word number

getLexicalFile

public ILexFile getLexicalFile()
Description copied from interface: ISynset
Returns a description of the lexical file. In wordnet data files, the lexical file number is a two digit decimal integer representing the name of the lexicographer file containing the synset for the sense.

Specified by:
getLexicalFile in interface ISynset
Returns:
the lexical file object that describes the lexical file in which this synset is stored

getRelatedMap

public java.util.Map<IPointer,java.util.List<ISynsetID>> getRelatedMap()
Description copied from interface: ISynset
Returns an immutable map from semantic pointers to immutable lists of synsets. Note that this only returns synsets related by semantic pointers (i.e., non-lexical pointers). To obtain lexical pointers, call IWord.getRelatedMap() on the appropriate word.

Specified by:
getRelatedMap in interface ISynset
Returns:
a non-null, unmodifiable map from pointers to synsets

getRelatedSynsets

public java.util.List<ISynsetID> getRelatedSynsets(IPointer type)
Description copied from interface: ISynset
Returns an immutable list of the ids of all synsets that are related to this synset by the specified pointer type. Note that this only returns a non-empty result for semantic pointers (i.e., non-lexical pointers). To obtain lexical pointers, call IWord.getRelatedWords()() on the appropriate object.

If there are no such synsets, this method returns the empty list.

Specified by:
getRelatedSynsets in interface ISynset
Parameters:
type - the pointer for which related synsets are to be retrieved.
Returns:
the list of synsets related by the specified pointer; if there are no such synsets, returns the empty list

getRelatedSynsets

public java.util.List<ISynsetID> getRelatedSynsets()
Description copied from interface: ISynset
Returns an immutable list of synset ids for all synsets that are connected by pointers to this synset. Note that the related synsets returned by this call are related by semantic pointers (as opposed to lexical pointers, which are relationships between IWord objects.

Specified by:
getRelatedSynsets in interface ISynset
Returns:
a list of all synsets semantically related to the current synset

isAdjectiveSatellite

public boolean isAdjectiveSatellite()
Description copied from interface: ISynset
Returns true if this synset is an adjective satellite; false otherwise.

Specified by:
isAdjectiveSatellite in interface ISynset
Returns:
true if this synset represents an adjective satellite; false otherwise.

isAdjectiveHead

public boolean isAdjectiveHead()
Description copied from interface: ISynset
Returns true if this synset is an adjective head; false otherwise.

Specified by:
isAdjectiveHead in interface ISynset
Returns:
true if this synset represents an adjective head; false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

zeroFillOffset

public static java.lang.String zeroFillOffset(int offset)
Takes an integer in the closed range [0,99999999] and converts it into an eight decimal digit zero-filled string. E.g., "1" becomes "00000001", "1234" becomes "00001234", and so on. This is used for the generation of synset and word numbers.

Parameters:
offset - the offset to be converted
Returns:
the zero-filled string representation of the offset
Throws:
java.lang.IllegalArgumentException - if the specified offset is not in the valid range of [0,99999999]
Since:
JWI 2.1.0

checkOffset

public static int checkOffset(int offset)
Throws an exception if the specified offset is not in the valid range of [0,99999999].

Parameters:
offset - the offset to be checked
Returns:
the checked offset
Throws:
java.lang.IllegalArgumentException - if the specified offset is not in the valid range of [0,99999999]
Since:
JWI 2.1.0

isLegalOffset

public static boolean isLegalOffset(int offset)
Returns true an exception if the specified offset is not in the valid range of [0,99999999].

Parameters:
offset - the offset to be checked
Returns:
true if the specified offset is in the closed range [0, 99999999]; false otherwise.
Since:
JWI 2.2.0


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.