Hello, there! I thought it would be interesting to implement some readability algorithms in javascript.
Everything is written in ES6, transpiled by Babel, and bundled using Browserify. Tests are written with Mocha.
All of the functionality is found in the Wordsmith
object. Here is an overview of its methods:
Wordsmith.syllableCount(data)
: wheredata
can be a string or an array of strings. Returns the total number of syllables found in the string or null if you input an invalid value.Wordsmith.sentenceCount(string)
: returns the number of sentences found in the string by using the delimiter/[\.?!]/
Wordsmith.wordCount(string)
: returns the number of words found in the string.Wordsmith.removePuctuation(string)
: removes everything except spaces and A-z characters.
These methods are used to implement these readability algorithms:
Wordsmith.fleschKincaidGradeLevel(string)
: returns the Flesch-Kincaid Grade Level of the input string.Wordsmith.fleschReadingEaseScore(string)
: returns the Flesch Reading Ease Score of the input string.
Make sure you have yarn installed. Then just run yarn build
. This will place wordsmith.min.js
into this dist/
directory.
Just run yarn test