public class Word
extends java.lang.Object
implements java.util.Comparator
This class is now immutable.
Constructor and Description |
---|
Word()
Constructs a new Word.
|
Word(java.lang.String word,
int score)
Constructs a new Word.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2)
Compares two words, mostly for the purpose of sorting words.
|
boolean |
equals(java.lang.Object o)
Indicates if this word is equal to another one.
|
int |
getCost()
A cost measures how close a match this word was to the original word
|
java.lang.String |
getWord()
gets suggested spelling
|
void |
setWord(java.lang.String word)
sets suggested spelling
|
java.lang.String |
toString()
returns the suggested spelling
|
public Word(java.lang.String word, int score)
word
- The text of a word.score
- The word's distance costpublic Word()
public int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
o1
- the first wordo2
- the second wordpublic boolean equals(java.lang.Object o)
equals
in interface java.util.Comparator
equals
in class java.lang.Object
o
- The other word to comparepublic java.lang.String getWord()
public void setWord(java.lang.String word)
word
- The text to set for suggestd spellingpublic int getCost()
EditDistance
public java.lang.String toString()
toString
in class java.lang.Object