Formula to detect the grade level of text according to the (revised) Spache readability formula.
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Related
- Contribute
- Security
- License
This package exposes an algorithm to detect ease of reading of English texts.
You’re probably dealing with natural language, and know you need this, if you’re here!
This algorithm isn’t based on syllabbles compared to some other algorithms, which means it’s quicker to calculate.
See spache
for a list of words which count as “known”.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install spache-formula
In Deno with esm.sh
:
import {spacheFormula} from 'https://esm.sh/spache-formula@2'
In browsers with esm.sh
:
<script type="module">
import {spacheFormula} from 'https://esm.sh/spache-formula@2?bundle'
</script>
import {spacheFormula} from 'spache-formula'
spacheFormula({word: 30, sentence: 2, unfamiliarWord: 6}) // => 4.114
spacheFormula({word: 30, sentence: 2}) // => 2.474
spacheFormula() // => NaN
This package exports the identifier spacheFormula
.
There is no default export.
Given the number of words (word
), the number of sentences (sentence
), and
the number of unique unfamiliar words (unfamiliarWord
) in a document, returns
the grade level associated with the document.
Counts from input document.
Number of sentences (number
, required).
Number of words (number
, required).
Number of unfamiliar words (number
, default: 0
).
Grade level associated with the document (number
).
This package is fully typed with TypeScript.
It exports the additional type Counts
.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
automated-readability
— uses character count instead of error-prone syllable parsercoleman-liau
— uses letter count instead of an error-prone syllable parserdale-chall-formula
— uses a dictionary, suited for higher reading levelsflesch
— uses syllable countflesch-kincaid
— likeflesch
, returns U.S. grade levelsgunning-fog
— uses syllable count, needs POS-tagging and NERsmog-formula
— likegunning-fog
, without the need for advanced NLP tasks
Yes please! See How to Contribute to Open Source.
This package is safe.