defmodule Words do
    @doc """
    Count the number of words in the sentence.

    Words are compared case-insensitively.
    """
    @spec count(String.t) :: map
    def count(sentence) do
        tokenized_sentence = String.split(sentence, ~r{\W}, trim: true)
        blanked_punctuation = Enum.map(tokenized_sentence, (fn x -> String.split(x, ~r{\W}) end))
        removed_punctuation = Enum.reject(blanked_punctuation, (fn x -> x == "" end))
        removed_punctuation
        Enum.reduce(removed_punctuation, Map.new(), (fn (x, acc) -> Map.update(acc, List.first(x), 1, (fn y -> (y + 1) end)) end))
    end
end
