WordCounter
Counts words from either a file or a website, and prints a report to stdout.
Installation
Add this line to your application's Gemfile:
gem 'word_counter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install word_counter
Usage
To count a website's words:
$ word_counter www.example.com
Results:
2 Domain
2 Example
2 domain
2 examples
2 for
2 in
1 More
1 This
1 You
1 asking
1 be
To count a file's words:
$ word_counter ./path/to/my/file.txt
Use the -s
switch to also report which lines contained the counted word (can result in lot of text output, so you might want to pipe it to less
):
$ word_counter www.example.com -s | less
Results:
2 Domain
1: Example Domain
2 Example
1: Example Domain
2 domain
1: This domain is established to be used for illustrative examples in documents. You may use this
2: domain in examples without prior coordination or asking for permission.
2 examples
1: This domain is established to be used for illustrative examples in documents. You may use this
2: domain in examples without prior coordination or asking for permission.
With all the options:
$ word_counter www.example.com -s -c | less -R
Options
-
-c
Colorize output -
-s
Show sentences containing the words in question
Roadmap
- Ignore common words (a, for, it, the, of, etc.)
- Ignore case
Contributing
- Fork it ( http://github.com/wulftone/word_counter/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request