Parsing Engine

danbikel.parser
Class Word

java.lang.Object
  extended by danbikel.parser.Word
All Implemented Interfaces:
SexpConvertible, Serializable, Cloneable

public class Word
extends Object
implements Serializable, Cloneable, SexpConvertible

A Word object is a structured representation of a word. It includes:

See Also:
WordFactory, Words, WordFeatures, Serialized Form

Field Summary
protected  Symbol features
          A word-feature vector of word.
protected  Symbol tag
          The part-of-speech of word.
protected  Symbol word
          The word itself.
 
Constructor Summary
protected Word()
          Constructs a new instance with null for all data members.
  Word(Sexp s)
          Constructs a word using the symbols contained in the specified S-expression, which must be a list of at least two symbols.
  Word(Symbol word, Symbol tag)
          Creates a new Word object with the specified word and part of speech.
  Word(Symbol word, Symbol tag, Symbol features)
          Creates a new Word object with the specified word, part of speech and word-feature vector.
 
Method Summary
protected  void checkSexp(Sexp s)
          Checks that the S-expression passed to Word(Sexp) is the right format.
 Object clone()
          Returns a clone of this object, which is effectively a deep copy, since all data members of unique Symbol references.
 Word copy()
          Returns a clone of this object.
 boolean equals(Object obj)
          Determines whether two Word objects are equal.
 Symbol features()
          Returns the features of this word, or null if no features have been set for this word.
 int hashCode()
          Returns a hash value for this object.
 Word set(Symbol word, Symbol tag, Symbol features)
          Sets all three data members for this word.
 void setFeatures(Symbol features)
          Sets the features for this word.
 void setTag(Symbol tag)
          Sets the part-of-speech tag for this word.
 void setWord(Symbol word)
          Sets the word itself of this Word object.
 Symbol tag()
          Returns the part-of-speech tag of this word.
 Sexp toSexp()
          Converts this object to an S-expression.
 String toString()
          Converts this Word object to a string (in S-expression format).
 Symbol word()
          Returns the word itself of this Word object.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

word

protected Symbol word
The word itself.


tag

protected Symbol tag
The part-of-speech of word.


features

protected Symbol features
A word-feature vector of word.

See Also:
WordFeatures
Constructor Detail

Word

protected Word()
Constructs a new instance with null for all data members.


Word

public Word(Symbol word,
            Symbol tag)
Creates a new Word object with the specified word and part of speech.

Parameters:
word - the word itself (all lowercase).
tag - its part-of-speech tag.

Word

public Word(Symbol word,
            Symbol tag,
            Symbol features)
Creates a new Word object with the specified word, part of speech and word-feature vector.

Parameters:
word - the word
tag - the word's part of speech
features - the word's feature vector (see WordFeatures)

Word

public Word(Sexp s)
Constructs a word using the symbols contained in the specified S-expression, which must be a list of at least two symbols. The first symbol is taken to be the word, the second its part of speech. The optional third symbol is the word's feature vector (features is left null if the specified list has only two elements).

Parameters:
s - the S-expression from which to construct a new Word instance; this S-expression must be a SexpList of length at least two, and containing all Symbol objects as its elements
Method Detail

checkSexp

protected void checkSexp(Sexp s)
Checks that the S-expression passed to Word(Sexp) is the right format. Throws an IllegalArgumentException if the specified Sexp is not in the right format.

Parameters:
s - the S-expression from which to construct a new Word instance; this S-expression must be a SexpList of length at least two, and containing all Symbol objects as its elements

word

public Symbol word()
Returns the word itself of this Word object.


setWord

public void setWord(Symbol word)
Sets the word itself of this Word object.

Parameters:
word - the word itself

tag

public Symbol tag()
Returns the part-of-speech tag of this word.


setTag

public void setTag(Symbol tag)
Sets the part-of-speech tag for this word.

Parameters:
tag - the part-of-speech tag

features

public Symbol features()
Returns the features of this word, or null if no features have been set for this word.


setFeatures

public void setFeatures(Symbol features)
Sets the features for this word.


set

public Word set(Symbol word,
                Symbol tag,
                Symbol features)
Sets all three data members for this word.

Returns:
this Word object

hashCode

public int hashCode()
Returns a hash value for this object.

Overrides:
hashCode in class Object
Returns:
the hash value for this object.

equals

public boolean equals(Object obj)
Determines whether two Word objects are equal.

Overrides:
equals in class Object
Parameters:
obj - the Word object to compare with.

toString

public String toString()
Converts this Word object to a string (in S-expression format).

Overrides:
toString in class Object
Returns:
the string representation.

clone

public Object clone()
Returns a clone of this object, which is effectively a deep copy, since all data members of unique Symbol references.

Overrides:
clone in class Object
Returns:
a clone of this object

copy

public Word copy()
Returns a clone of this object. A shallow copy is all that is needed, as all data members are basic types or references to unique objects (symbols).


toSexp

public Sexp toSexp()
Description copied from interface: SexpConvertible
Converts this object to an S-expression.

Specified by:
toSexp in interface SexpConvertible
Returns:
the S-expression that represents an instance of an implementor of this class

Parsing Engine

Author: Dan Bikel.