public static Map<String, Integer> countWords(ArrayList<String> list)
    {
        HashMap<String, Integer> result = new HashMap<String, Integer>();

        for (String word : list) {
            if (result.containsKey(word)) {
                result.put(word, result.get(word) + 1);
            }
            else {
                result.put (word, 1);
            }
        }


        return result;
    }