edu.mit.jwi.item
Class SenseKey

java.lang.Object
  extended by edu.mit.jwi.item.SenseKey
All Implemented Interfaces:
IHasPOS, ISenseKey, java.io.Serializable, java.lang.Comparable<ISenseKey>

public class SenseKey
extends java.lang.Object
implements ISenseKey

Concrete, default implementation of the ISenseKey interface.

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

Constructor Summary
SenseKey(java.lang.String lemma, int lexID, ISynset synset)
          Constructs a new sense key.
SenseKey(java.lang.String lemma, int lexID, POS pos, boolean isAdjSat, ILexFile lexFile)
          Constructs a new sense key.
SenseKey(java.lang.String lemma, int lexID, POS pos, boolean isAdjSat, ILexFile lexFile, java.lang.String originalKey)
          Constructs a new sense key.
SenseKey(java.lang.String lemma, int lexID, POS pos, ILexFile lexFile, java.lang.String headLemma, int headLexID, java.lang.String originalKey)
          Constructs a new sense key.
 
Method Summary
protected  void checkHeadSet()
          Throws an exception if the head is not yet set.
 int compareTo(ISenseKey key)
           
 boolean equals(java.lang.Object obj)
           
 int getHeadID()
          Returns the head id for this sense key.
 java.lang.String getHeadWord()
          Returns the head word for this sense key.
 java.lang.String getLemma()
          The lemma (root form) of the word indicated by this key.
 ILexFile getLexicalFile()
          Returns the lexical file associated with this sense key.
 int getLexicalID()
          Returns the lexical id for this sense key, which is a non-negative integer.
 POS getPOS()
          Returns the associated part of speech for this object.
 int getSynsetType()
          Returns the synset type for the key.
 int hashCode()
           
 boolean isAdjectiveSatellite()
          Returns true if this sense key points to an adjective satellite; false otherwise.
 boolean needsHeadSet()
          This method will always return false if the ISenseKey.isAdjectiveSatellite() returns false.
 void setHead(java.lang.String headLemma, int headLexID)
          This method is used to set the head for sense keys for adjective satellites, and it can only be called once, directly after the relevant word is created.
 java.lang.String toString()
           
static java.lang.String toString(ISenseKey key)
          Returns a a string representation of the specified sense key object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SenseKey

public SenseKey(java.lang.String lemma,
                int lexID,
                ISynset synset)
Constructs a new sense key.

Parameters:
lemma - the lemma for the sense key
lexID - the lexical id of the sense key
synset - the synset for the sense key
Throws:
java.lang.NullPointerException - if either the lemma or synset is null
Since:
JWI 2.1.0

SenseKey

public SenseKey(java.lang.String lemma,
                int lexID,
                POS pos,
                boolean isAdjSat,
                ILexFile lexFile,
                java.lang.String originalKey)
Constructs a new sense key.

Parameters:
lemma - the lemma; may not be null
lexID - the lexical id
pos - the part of speech; may not be null
isAdjSat - true if this represents an adjective satellite; false otherwise
lexFile - the lexical file; may not be null
originalKey - the original key string
Throws:
java.lang.NullPointerException - if the lemma, lexical file, or original key is null
Since:
JWI 2.1.0

SenseKey

public SenseKey(java.lang.String lemma,
                int lexID,
                POS pos,
                ILexFile lexFile,
                java.lang.String headLemma,
                int headLexID,
                java.lang.String originalKey)
Constructs a new sense key.

Parameters:
lemma - the lemma; may not be null
lexID - the lexical id
pos - the part of speech; may not be null
lexFile - the lexical file; may not be null
originalKey - the original key string
headLemma - the head lemma
headLexID - the head lexical id; ignored if head lemma is null
Throws:
java.lang.NullPointerException - if the lemma, lexical file, or original key is null
Since:
JWI 2.1.0

SenseKey

public SenseKey(java.lang.String lemma,
                int lexID,
                POS pos,
                boolean isAdjSat,
                ILexFile lexFile)
Constructs a new sense key.

Parameters:
lemma - the lemma; may not be null
lexID - the lexical id
pos - the part of speech; may not be null
isAdjSat - true if this is an adjective satellite sense key; false otherwise
lexFile - the lexical file; may not be null
Throws:
java.lang.NullPointerException - if the lemma, part of speech, or lexical file is null
Since:
JWI 2.1.0
Method Detail

getLemma

public java.lang.String getLemma()
Description copied from interface: ISenseKey
The lemma (root form) of the word indicated by this key. The returned lemma will not be null, empty, or all whitespace.

Specified by:
getLemma in interface ISenseKey
Returns:
the lemma for this key

getLexicalID

public int getLexicalID()
Description copied from interface: ISenseKey
Returns the lexical id for this sense key, which is a non-negative integer.

Specified by:
getLexicalID in interface ISenseKey
Returns:
the non-negative lexical id for this sense key

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.

getSynsetType

public int getSynsetType()
Description copied from interface: ISenseKey
Returns the synset type for the key. The synset type is a one digit decimal integer representing the synset type for the sense.
 1=NOUN
 2=VERB
 3=ADJECTIVE
 4=ADVERB
 5=ADJECTIVE SATELLITE
 

Specified by:
getSynsetType in interface ISenseKey
Returns:
the synset type, an integer between 1 and 5, inclusive

isAdjectiveSatellite

public boolean isAdjectiveSatellite()
Description copied from interface: ISenseKey
Returns true if this sense key points to an adjective satellite; false otherwise.

Specified by:
isAdjectiveSatellite in interface ISenseKey
Returns:
true if this sense key points to an adjective satellite; false otherwise

getLexicalFile

public ILexFile getLexicalFile()
Description copied from interface: ISenseKey
Returns the lexical file associated with this sense key. This method should not return null. If the lexical file is unknown, an appropriate object to return is an UnknownLexFile object obtained via the LexFile.getLexicalFile(int) method.

Specified by:
getLexicalFile in interface ISenseKey
Returns:
the lexical file associated with this sense key

setHead

public void setHead(java.lang.String headLemma,
                    int headLexID)
Description copied from interface: ISenseKey
This method is used to set the head for sense keys for adjective satellites, and it can only be called once, directly after the relevant word is created. If this method is called on a sense key that has had its head set already, or is not an adjective satellite, it will throw an exception.

Specified by:
setHead in interface ISenseKey
Parameters:
headLemma - the head lemma to be set

getHeadWord

public java.lang.String getHeadWord()
Description copied from interface: ISenseKey
Returns the head word for this sense key. The head word is only present if the sense is an adjective satellite synset, and it is the lemma of the first word of the satellite's head synset. If this sense key is not for an adjective synset, this method returns null. If non- null, the head word will be neither empty or nor all whitespace.

Specified by:
getHeadWord in interface ISenseKey
Returns:
the head word for this adjective satellite synset, or null if the indicated sense is not an adjective satellite

getHeadID

public int getHeadID()
Description copied from interface: ISenseKey
Returns the head id for this sense key. The head id is only present if the sense is an adjective satellite synset, and is a two digit decimal integer that, when appended onto the head word, uniquely identifies the sense within a lexicographer file. If this sense key is not for an adjective synset, this method returns -1.

Specified by:
getHeadID in interface ISenseKey
Returns:
the head id for this adjective satellite synset, or -1 if the indicated sense is not an adjective satellite

needsHeadSet

public boolean needsHeadSet()
Description copied from interface: ISenseKey
This method will always return false if the ISenseKey.isAdjectiveSatellite() returns false. If that method returns true, this method will only return true if ISenseKey.setHead(String, int) has not yet been called.

Specified by:
needsHeadSet in interface ISenseKey
Returns:
true if the head lemma and lexical id need to be set; false otherwise.

compareTo

public int compareTo(ISenseKey key)
Specified by:
compareTo in interface java.lang.Comparable<ISenseKey>

toString

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

checkHeadSet

protected void checkHeadSet()
Throws an exception if the head is not yet set.

Throws:
java.lang.IllegalArgumentException - if the needsHeadSet() method returns true.
Since:
JWI 2.2.0

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 static java.lang.String toString(ISenseKey key)
Returns a a string representation of the specified sense key object.

Parameters:
key - the sense key to be encoded as a string
Returns:
the string representation of the sense key
Throws:
java.lang.NullPointerException - if the specified key is null
Since:
JWI 2.1.0


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