import java.util.*;
import java.lang.String;

public class WordCount {
  /**
   * Phrase takes a string and returns a map that counts
   * how many of each word are in the phrase
   * @param thePhrase The phrase to work with
   * @return          The map with word counts
   */
  public Map<String, Integer> Phrase(String thePhrase) {
    Map<String, Integer> ret = new HashMap<String, Integer>();
    thePhrase = thePhrase.replaceAll("[^a-zA-Z0-9 ]", "").replaceAll(" +"," ").toLowerCase();
    String[] words = thePhrase.split(" ");
    for(int i = 0; i < words.length; i++) {
      int wordCount = 0;
      if(ret.containsKey(words[i])) {
        wordCount = ret.get(words[i]); 
      }
      if(words[i].trim() != "") {
        ret.put(words[i], wordCount+1);
      }
    }
    return ret;
  }
}
