/** * Allocates a word in the dictionary */ protected void putWord(String word) { String code = getCode(word); LinkedList list = (LinkedList) mainDictionary.get(code); if (list != null) { list.add(word); } else { list = new LinkedList(); list.add(word); mainDictionary.put(code, list); } }
/** * Returns true if the word is correctly spelled against the current word list. * @param word The word to checked in the dictionary * @return indication if the word is in the dictionary */ public boolean isCorrect(String word) { List possible = getWords(getCode(word)); if (possible.contains(word)) return true; //JMH should we always try the lowercase version. If I dont then capitalised //words are always returned as incorrect. else if (possible.contains(word.toLowerCase())) return true; return false; } }