package edu.neu.ccs.demeter; /** A terminal class for parsing a word. Put Word in a class dictionary to represent a word (any sequence of non-whitespace characters) in an input sentence. */ final public class Word implements java.io.Serializable { private String str; /** Construct an empty word. */ public Word() { str = ""; } /** Construct a Word from a String. Note that a Word created outside of the parser is not constrained to be a single word. */ public Word(String s) { str = s; } /** Construct a Word from an Object by converting it to a String with {@link Object#toString()}. Note that a Word created outside of the parser is not constrained to be a single word. */ public Word(Object obj) { str = obj.toString(); } public String toString() { return str; } public int hashCode() { return str.hashCode(); } public boolean equals(Object word) { return (word instanceof Word) && str.equals(((Word) word).str); } }