Skip to content

reading-level returns the numeric reading level of a sample text

Notifications You must be signed in to change notification settings

Darkenetor/reading-level

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reading-level

reading-level returns the numeric reading level of a sample text based on the Flesch-Kincaid Grade Level Readability Formula.

const { readingLevel } = require('reading-level')

const text1 = 'this is a simple sentence'
const text2 = 'the perpendicular platypus perused the panoramic pyramid'
const text3 = '0120131908 74123987419823'
const text4 = ''

readingLevel(text1) // 3 
readingLevel(text2) // 21
readingLevel(text3) // 'Either no sentences or words, please enter valid text'
readingLevel(text4) // 'Either no sentences or words, please enter valid text'

readingLevel(text2, 'full') // { sentences: 1,
                            //   words: 7,
                            //   syllables: 20,
                            //   unrounded: 20.854285714285712,
                            //   rounded: 21 }
  • all numeric values and punctuation are stripped out before analysis
  • pass 'full' as a second argument to get the breakdown
  • this seems to work with languages besides english, however I have no idea about the accuracy of the results

test

npm run test

About

reading-level returns the numeric reading level of a sample text

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%