edu.mit.jwi.item
Class WordID

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

public class WordID
extends Object
implements IWordID

Default implementation of the IWordID interface.

Since:
JWI 1.0
Version:
2.2.2
Author:
Mark A. Finlayson

Field Summary
static String unknownLemma
          Represents an unknown lemma for the toString() method.
static String unknownWordNumber
          Represents an unknown word number for the toString() method.
static 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, 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, String lemma)
          Constructs a fully specified word id
WordID(ISynsetID id, String lemma)
          Constructs a word id from the specified arguments.
 
Method Summary
 boolean equals(Object obj)
           
 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(String value)
          Parses the result of the toString() method back into an WordID.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

wordIDPrefix

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

Since:
JWI 2.0.0
See Also:
Constant Field Values

unknownLemma

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

Since:
JWI 2.0.0
See Also:
Constant Field Values

unknownWordNumber

public static final 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:
IllegalArgumentException - if the offset or number are not legal
Since:
JWI 1.0

WordID

public WordID(int offset,
              POS pos,
              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:
NullPointerException - if the synset id is null
IllegalArgumentException - if the lemma is empty or all whitespace
Since:
JWI 1.0

WordID

public WordID(ISynsetID id,
              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:
NullPointerException - if the synset id is null
IllegalArgumentException - if the lemma is empty or all whitespace
Since:
JWI 1.0

WordID

public WordID(ISynsetID id,
              int num,
              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:
NullPointerException - if the synset id is null
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.

Specified by:
getWordNumber in interface IWordID
Returns:
an integer between 1 and 255, inclusive.

getLemma

public String getLemma()
Description copied from interface: IWordID
Returns the lemma (word root) associated with this word.

Specified by:
getLemma in interface IWordID
Returns:
the lemma (word root) associated with this word.

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 Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

parseWordID

public static IWordID parseWordID(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:
IllegalArgumentException - if the specified string does not represent a word id
NullPointerException - if the specified string is null
Since:
JWI 1.0


Copyright © 2011. All Rights Reserved.