Given a book in a text file (http://www.loyalbooks.com/download/text/Railway-Children-by-E-Nesbit.txt for example)
- Write an application that outputs the individual words that appear in the book, and how many times that word appears in the text file.
- The second part is to also output whether the number of times each word appears is a prime number. The following assumptions can be made: Ignore punctuation and capitalisation TDD is expected
- JavaScript
- Test framework: Jasmine
- Version Control System: GIT
- Clone this repository by typing the following in the command line.
git clone git@github.com:AaronRodrigues/wordcount.git
- Navigate to the directory.
- Open index.html in the views folder in a web browser.
- In the browser, select the text file from the sample-text folder.
- You can choose any other text file stored on your computer as well.
- A list of words and their frquency in the text will be displayed.
- If the word frequency is a Prime Number, it is indicated as shown in the screenshot.
- Tests can be run by opening SpecRunner.html in a web browser.
- WordCount object takes string of text as an argument and stores it.
- Converts a body of text into a an array of lowercase words.
- WordCount removes duplicate words from array and saves this array as a reference array.
- Uses this reference array and counts the words in the text.
- Arrange the words and frequency in decreasing order.
- Checks if a number is Prime and indicates this in the view.
I found difficulty in reading the text file using JavaScript. I found this easier to do in languages like Ruby. I used a FileReader script which I was not sure how to test.
- Add more styling to index.html
- Add code coverage and continous integration using Travis-CI