import java.util.*;

public class WordFrequencies {
  public static Map<String, Integer> map;

  public static void setUpHashTable(String str) {
    map = new HashMap<String, Integer>();
    String[] words = str.split(" ");
    for (String word : words) {
      if (map.containsKey(word))
        map.put(word, map.get(word) + 1);
      else
        map.put(word, 1);
    }
  }

  public static int frequencies(String given) {
    if (map.containsKey(given))
      return map.get(given);
    else
      return 0;
  }
  public static void main(String[] args) {
    String str = "hello this is a test line supposedly representing a book. the book is very short.";
    setUpHashTable(str);
    System.out.println(frequencies("is"));
  }
}

@@ -205,16 +205,48 @@
 s = str.
+replaceAll(%22%5B%5EA-Za-z0-9%5D%22, %22 %22).
 split(%22 

Update WordFrequencies.java