| 6 | |
| 7 | public class Question { |
| 8 | public static Hashtable<String, Integer> setupDictionary(String[] book) { |
| 9 | Hashtable<String, Integer> table = new Hashtable<String, Integer>(); |
| 10 | for (String word : book) { |
| 11 | word = word.toLowerCase(); |
| 12 | if (word.trim() != "") { |
| 13 | if (!table.containsKey(word)) { |
| 14 | table.put(word, 0); |
| 15 | } |
| 16 | table.put(word, table.get(word) + 1); |
| 17 | } |
| 18 | } |
| 19 | return table; |
| 20 | } |
| 21 | public static int getFrequency(Hashtable<String, Integer> table, String word) { |
| 22 | if (table == null || word == null) { |
| 23 | return -1; |