public class Dictionary
extends java.lang.Object
implements java.lang.Iterable<java.lang.String>
Dictionary is a set of words used to determine
whether a given solution for a grid is legal. The score for a given
word depends on its length and its frequency in the dictionary.
This class is immutable, so it is thread-safe.| Modifier and Type | Field and Description |
|---|---|
int |
MAX_WORD_LEN |
| Modifier and Type | Method and Description |
|---|---|
int |
getScore(int wordLength)
Returns the score that a word would have gotten based only on
it's length.
|
java.util.Iterator<java.lang.String> |
iterator() |
static Dictionary |
makeDict(java.lang.String file)
Constructs a dictionary from an input file.
|
boolean |
member(java.lang.String word)
Determines whether a given word is in the dictionary.
|
int |
score(java.lang.String word)
Computes the score for the given word, based on its length
and the distribution of words having that length in the
dictionary.
|
public final int MAX_WORD_LEN
public static Dictionary makeDict(java.lang.String file)
file - - contains the words for the dictionarypublic boolean member(java.lang.String word)
word - public int score(java.lang.String word)
word - public int getScore(int wordLength)
wordLength - public java.util.Iterator<java.lang.String> iterator()
iterator in interface java.lang.Iterable<java.lang.String>