WordSource processes streams of words, performing analytics on them as it goes.
A WordSource is a source of words. You can get words from it by calling the next_word method.
It keeps analytical information of each word that it has seen.
There are several potential sources for the words.
In this example we assume that the word source has been initialised with the following string: "lorem,ipsum,ipsum"
word_source = StringWordSource.new("lorem,ipsum,ipsum")
word_source.next_word
# => "lorem"
word_source.next_word
# => "ipsum"
word_source.next_word
# => "ipsum"
word_source.top_5_words
# => ["ipsum","lorem",nil,nil,nil]
word_source.top_5_consonants
# => ["m","p","s","l","r"]
word_source.count
# => 3 # total words seen word_source = StringWordSource.new("lorem,ipsum,ipusum")
# This will run until there are no more words for the source implementation.
word_source.run
# => true- Implement FileWordSource that pulls in words from a file; include the methods described above. Use lorem_ipsum.txt to test.
- Add callbacks on specific words e.g. every time "semper" is encountered, call those callbacks registered for "semper"
- implement a WordSource that uses the Twitter API (instead of loading words from a file)