com.swabunga.spell.engine
Class Word
java.lang.Object
|
+--com.swabunga.spell.engine.Word
- All Implemented Interfaces:
- java.util.Comparator
- public class Word
- extends java.lang.Object
- implements java.util.Comparator
The Word object holds information for one suggested spelling.
It contains both the suggested word string and the distance cost, which represents how different the suggested
word is from the misspelling.
This class is now immutable.
Constructor Summary |
Word()
|
Word(java.lang.String word,
int score)
|
Method Summary |
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)
|
int |
getCost()
A cost measures how close a match this word was to the original word |
java.lang.String |
getWord()
gets suggested spelling |
java.lang.String |
toString()
returns the suggested spelling |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Word
public Word(java.lang.String word,
int score)
Word
public Word()
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Compares two words, mostly for the purpose of sorting words.
- Specified by:
compare
in interface java.util.Comparator
- Parameters:
o1
- the first wordo2
- the second word- Returns:
- -1 if the first word is more similar to the mispelled word
1 if the second word is more similar to the misspelled word
0 if both words are equally similar
equals
public boolean equals(java.lang.Object o)
- Specified by:
equals
in interface java.util.Comparator
- Overrides:
equals
in class java.lang.Object
getWord
public java.lang.String getWord()
- gets suggested spelling
- Returns:
- the actual text of the suggest spelling
getCost
public int getCost()
- A cost measures how close a match this word was to the original word
- Returns:
- 0 if an exact match. Higher numbers are worse matches.
- See Also:
EditDistance
toString
public java.lang.String toString()
- returns the suggested spelling
- Overrides:
toString
in class java.lang.Object