Write a module that takes a file path as argument and returns a map with word counts.
- The module name is up to you
- Additional modules can be implemented as needed
- The file will always be a text file
- The counting logic should be case insensitive
- Other than the apostrophe in a contraction all forms of punctuation are ignored
- The words can be separated by any form of whitespace (ie "\t", "\n", " ")
- A word is:
- A number composed of one or more ASCII digits (ie "0" or "1234") OR
- A simple word composed of one or more ASCII letters (ie "a" or "they") OR
- A contraction of two simple words joined by a single apostrophe (ie "it's" or "they're")
For example, this file:
That's the password: 'PASSWORD 123'!", cried the Special Agent.
So I fled.
would return:
%{
"that's" => 1,
"the" => 2,
"password" => 2,
"123" => 1,
"cried" => 1,
"special" => 1,
"agent" => 1,
"so" => 1,
"i" => 1,
"fled" => 1
}