WikiWords
This small tool takes as input a Wikipedia pageID and reports the top N words on that page in terms of frequency. Data is fetched from Wikipeda via Wikipedias REST API interface. Words with the same frequency are grouped by default. Only words of 4 or more characters are considered to increase report usefulness.
Installation
Add this line to your application's Gemfile:
gem 'wiki_words'
And then execute:
$ bundle
Or install it yourself as:
$ gem install wiki_words
Usage
This gem is an executable gem that can be used via cmd as follows:
$ wiki_words
Use -h
for full usage details.
$ wiki_words -h
Wiki Words - version 0.1.0
Wikpedia word frequency reporting
Usage: wiki_words -p PAGEID -n TOP_N_WORDS
-p, --pageid PAGEID Wikipedia PAGEID of desired article for word analysis
-n, --top_n_words TOP_N_WORDS Top N words from the wikipedia article (optional)
-h, --help Print help
Providing a pageID will show a report for that specific page. Limit is also optional to refine the report to the highest frequency words only.
$ wiki_words -p 21721040 -n 9
Title: Stack Overflow (sorted by frequency) (limited to 9)
Frequency: 20 time(s) Words: |questions|
Frequency: 19 time(s) Words: |stack|
Frequency: 16 time(s) Words: |overflow|
Frequency: 12 time(s) Words: |users|
Frequency: 11 time(s) Words: |question, that|
Frequency: 10 time(s) Words: |site|
Frequency: 8 time(s) Words: |answer|
Frequency: 7 time(s) Words: |answers, reputation|
Frequency: 6 time(s) Words: |website, programming, their, only|
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/johnmfarrell1/wiki_words.
License
The gem is available as open source under the terms of the MIT License.