Fixes #19: Implementing reading time feature and tester file + update package.json #131
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added basic features for text analysis. In the beginning, my goal was to add reading-time features. However, I realized that word count, the level of writing (readability based on Flesch-Kincaid grade level) and reading-time are highly connected.
For instance, the formula for readability is formula_image
To get the level of writing, we need the number of words, and the formula to get reading time is the total number of words / word per minute. Besides the reading-level library that I use to get Flesch_Kincaid Grade, it also returns the count of words.
Since the three basic features are highly coupled, I think that coupling them together as one class will be better than implementing three different functions. I tried to implement the OOP concept into the function. Because an ES6 class does not fully support encapsulation, I used ES5 syntax with the closures concept in JavaScript to implement private members.
The analyzeText() function return analysis object that contains wordCount, readability, readingTime. The analyzeText() function contains two different public query functions, getAnalysis(), and getAsyAnalsis(). In case of using promise channing, getAsyAnalsis() can be used.
The tester file provides queries to check if functions work well, but it will need more functionality. Plus, I updated the package.json file since it caused an error on the previous pull-request
I'm not familiar with JavaScript so if you have any opinions, feel free to share your opinions. I will refect the opinions.