public final String correct(String word)
	{
      if(nWords.containsKey(word))
			return word;
      ArrayList<String> list = edits(word);
      HashMap<Integer, String> candidates = new HashMap<Integer, String>();
      for(String s : list)
			if(nWords.containsKey(s))
				candidates.put(nWords.get(s),s);
      if(candidates.size() > 0)
			return candidates.get(Collections.max(candidates.keySet()));
      for(String s : list)
			for(String w : edits(s))
				if(nWords.containsKey(w))
					candidates.put(nWords.get(w),w);
      return candidates.size() > 0 ? candidates.get(Collections.max(candidates.keySet())) : word;
   }