Class Dictionary

java.lang.Object
  extended by Dictionary

public class Dictionary
extends java.lang.Object

A dictionary manages a collection of known, correctly-spelled words.


Constructor Summary
Dictionary(java.lang.String filename)
          Constructs a dictionary of from words contained in given file.
 
Method Summary
 boolean isWord(java.lang.String word)
          Test whether the input word is present in the Dictionary.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dictionary

public Dictionary(java.lang.String filename)
           throws java.io.IOException
Constructs a dictionary of from words contained in given file. Each line of the file contains one word. Any leading or trailing whitespace should be removed, and any empty lines should be ignored.

Parameters:
filename - the path of a dictionary file
Throws:
java.io.IOException
Method Detail

isWord

public boolean isWord(java.lang.String word)
Test whether the input word is present in the Dictionary.

This check should be case insensitive. For example, if the Dictionary contains "dog" then isWord("DOG") should return true.

Parameters:
word - a string token to check. Assume any leading or trailing whitespace has already been removed.
Returns:
whether the word is in the dictionary