edu.mit.jwi.item
Class WordID

java.lang.Object
  extended by edu.mit.jwi.item.WordID
All Implemented Interfaces:
IHasPOS, IItemID<IWord>, IWordID, java.io.Serializable

public class WordID
extends java.lang.Object
implements IWordID

Default implementation of the IWordID interface.

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

Field Summary
static java.lang.String unknownLemma
          Represents an unknown lemma for the toString() method.
static java.lang.String unknownWordNumber
          Represents an unknown word number for the toString() method.
static java.lang.String wordIDPrefix
          String prefix for the toString() method.
 
Constructor Summary
WordID(int offset, POS pos, int num)
          Constructs a word id from the specified arguments.
WordID(int offset, POS pos, java.lang.String lemma)
          Constructs a word id from the specified arguments.
WordID(ISynsetID id, int num)
          Constructs a word id from the specified arguments.
WordID(ISynsetID id, int num, java.lang.String lemma)
          Constructs a fully specified word id
WordID(ISynsetID id, java.lang.String lemma)
          Constructs a word id from the specified arguments.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getLemma()
          Returns the lemma (word root) associated with this word.
 POS getPOS()
          Returns the associated part of speech for this object.
 ISynsetID getSynsetID()
          Returns the synset id object associated with this word.
 int getWordNumber()
          Returns the word number, which is a number from 1 to 255 that indicates the order this word is listed in the Wordnet data files.
 int hashCode()
           
static IWordID parseWordID(java.lang.String value)
          Parses the result of the toString() method back into an WordID.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

wordIDPrefix

public static final java.lang.String wordIDPrefix
String prefix for the toString() method.

Since:
JWI 2.0.0
See Also:
Constant Field Values

unknownLemma

public static final java.lang.String unknownLemma
Represents an unknown lemma for the toString() method.

Since:
JWI 2.0.0
See Also:
Constant Field Values

unknownWordNumber

public static final java.lang.String unknownWordNumber
Represents an unknown word number for the toString() method.

Since:
JWI 2.0.0
See Also:
Constant Field Values
Constructor Detail

WordID

public WordID(int offset,
              POS pos,
              int num)
Constructs a word id from the specified arguments. This constructor produces a word with an unknown lemma.

Parameters:
offset - the synset offset
pos - the part of speech; may not be null
num - the word number
Throws:
java.lang.IllegalArgumentException - if the offset or number are not legal
Since:
JWI 1.0

WordID

public WordID(int offset,
              POS pos,
              java.lang.String lemma)
Constructs a word id from the specified arguments. This constructor produces a word with an unknown word number.

Parameters:
offset - the synset offset
pos - the part of speech; may not be null
lemma - the lemma; may not be null, empty, or all whitespace
Since:
JWI 1.0

WordID

public WordID(ISynsetID id,
              int num)
Constructs a word id from the specified arguments. This constructor produces a word with an unknown lemma.

Parameters:
id - the synset id; may not be null
num - the word number
Throws:
java.lang.NullPointerException - if the synset id is null
java.lang.IllegalArgumentException - if the lemma is empty or all whitespace
Since:
JWI 1.0

WordID

public WordID(ISynsetID id,
              java.lang.String lemma)
Constructs a word id from the specified arguments. This constructor produces a word with an unknown word number.

Parameters:
id - the synset id; may not be null
lemma - the lemma; may not be null, empty, or all whitespace
Throws:
java.lang.NullPointerException - if the synset id is null
java.lang.IllegalArgumentException - if the lemma is empty or all whitespace
Since:
JWI 1.0

WordID

public WordID(ISynsetID id,
              int num,
              java.lang.String lemma)
Constructs a fully specified word id

Parameters:
id - the synset id; may not be null
num - the word number
lemma - the lemma; may not be null, empty, or all whitespace
Throws:
java.lang.NullPointerException - if the synset id is null
java.lang.IllegalArgumentException - if the lemma is empty or all whitespace, or the word number is not legal
Since:
JWI 1.0
Method Detail

getSynsetID

public ISynsetID getSynsetID()
Description copied from interface: IWordID
Returns the synset id object associated with this word.

Specified by:
getSynsetID in interface IWordID
Returns:
the synset id for this word; never null

getWordNumber

public int getWordNumber()
Description copied from interface: IWordID
Returns the word number, which is a number from 1 to 255 that indicates the order this word is listed in the Wordnet data files. If the word number has not been specified, will return -1. If this method returns -1, the IWordID.getLemma() method will return a non-null, non-empty string, non-whitespace string.

Specified by:
getWordNumber in interface IWordID
Returns:
an integer between 1 and 255, inclusive; or -1 if the word number has not been specified.

getLemma

public java.lang.String getLemma()
Description copied from interface: IWordID
Returns the lemma (word root) associated with this word. If this word id does not have a lemma specified (it was underspecified when constructed), this method will return null. If this method returns null, the IWordID.getWordNumber() method will return a positive number.

Specified by:
getLemma in interface IWordID
Returns:
the lemma (word root) associated with this word. May return null if the lemma has not been specified.

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.

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

parseWordID

public static IWordID parseWordID(java.lang.String value)
Parses the result of the toString() method back into an WordID. Word id's are always of the following format: WID-########-P-##-lemma where ######## is the eight decimal digit zero-filled offset of the associated synset, P is the upper case character representing the part of speech, ## is the two hexidecimal digit zero-filled word number (or ?? if unknown), and lemma is the lemma.

Parameters:
value - the string to be parsed
Returns:
WordID the parsed id
Throws:
java.lang.IllegalArgumentException - if the specified string does not represent a word id
java.lang.NullPointerException - if the specified string is null
Since:
JWI 1.0


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