dale-chall-formula
Version:
Formula to detect the grade level of text according to the (revised) Dale-Chall Readability Formula (1995)
54 lines (53 loc) • 1.81 kB
TypeScript
/**
* Given the number of words (`word`), the number of sentences (`sentence`),
* and the number of unique unfamiliar words in a document (`difficultWord`),
* returns the score associated with the document.
*
* @param {Counts} counts
* Counts from input document.
* @return {number}
* Score representing ease of reading.
*
* Pass it to `daleChallGradeLevel` to get grade levels.
*/
export function daleChallFormula(counts: Counts): number
/**
* Turn a dale–chall score into U.S. grade levels.
*
* @param {number} score
* Score representing ease of reading.
* @returns {[number, number]}
* Grade levels.
*
* | Score | Corresponding grade level | Return value |
* | -----------: | --------------------------------------- | ---------------- |
* | Less than 5 | Grade 4 and lower | `[0, 4]` |
* | Less than 6 | Grades 5 and 6 | `[5, 6]` |
* | Less than 7 | Grades 7 and 8 | `[7, 8]` |
* | Less than 8 | Grades 9 and 10 | `[9, 10]` |
* | Less than 9 | Grades 11 and 12 | `[11, 12]` |
* | Less than 10 | Grades 13 and 15 (College) | `[13, 15]` |
* | Higher | Grades 16 and higher (College Graduate) | `[16, Infinity]` |
*/
export function daleChallGradeLevel(score: number): [number, number]
/**
* Counts from input document.
*/
export type Counts = {
/**
* Number of sentences.
*/
sentence: number
/**
* Number of words.
*/
word: number
/**
* Number of difficult words.
*/
difficultWord?: number | undefined
}
/**
* Deprecated: please use the `Counts` type instead.
*/
export type DaleChallFormulaCounts = Counts