npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

text-readability-ts

v1.0.11

Published

npm package includes TypeScript and is designed to calculate various statistics from text in order to determine the readability, complexity, and grade level of a given corpus.

Downloads

284

Readme

text-readability-ts

This module provides a set of functions to calculate various readability scores for a given text. These scores can be used to estimate the reading difficulty level of the text include TypeScript.

The rewrite of the original text-readability module in JavaScript.

Installation

npm install text-readability-ts

or

yarn add text-readability-ts

Usage

import readability from 'text-readability-ts';

const text = 'This is a sample text.';
const score = readability.fleschKincaidReadingEase(text);
console.log(score);

const grade = readability.textStandard(text);
console.log(grade);

Available Functions

  • getGradeSuffix(grade: number): Returns the grade suffix of the given grade.
  • charCount(text: string, ignoreSpaces: boolean = true): Returns the character count of the given text.
  • letterCount(text: string, ignoreSpaces: boolean = true): Returns the letter count of the given text.
  • removePunctuation(text: string): Removes punctuation from the given text.
  • split(text: string): Splits the given text into an array of strings.
  • lexiconCount(text: string, removePunctuation: boolean = true): Calculates the number of words present in the text.
  • syllableCount(text: string, lang: string = 'en-US'): Returns the number of syllables present in the given text.
  • sentenceCount(text: string): Returns the number of sentences present in the given text.
  • averageSentenceLength(text: string): Returns the average sentence length of the given text.
  • averageSyllablePerWord(text: string): Returns the average syllable per word of the given text.
  • averageCharacterPerWord(text: string): Returns the average character per word of the given text.
  • averageLetterPerWord(text: string): Returns the average letter per word of the given text.
  • averageSentencePerWord(text: string): Returns the average sentence per word of the given text.
  • fleschReadingEase(text: string): Returns the Flesch Reading Ease Score.
  • fleschReadingEaseToGrade(score: number): Returns the grade level of the text using the Flesch Reading Ease Score.
  • fleschKincaidGrade(text: string): Returns the Flesch-Kincaid Grade of the given text.
  • polySyllableCount(text: string): Returns the polysyllable count of the given text.
  • smogIndex(text: string): Returns the SMOG index of the given text.
  • colemanLiauIndex(text: string): Returns the grade level of the text using the Coleman-Liau Formula.
  • automatedReadabilityIndex(text: string): Returns the ARI (Automated Readability Index) of the given text.
  • linsearWriteFormula(text: string): Returns the grade level using the Linsear Write Formula.
  • presentTense(word: string): Returns the present tense of the given word.
  • difficultWords(text: string, syllableThreshold: number = 2): Returns the number of difficult words in the given text.
  • daleChallReadabilityScore(text: string): Returns the New Dale-Chall Formula score of the given text.
  • daleChallToGrade(score: number): Returns the grade level using the New Dale-Chall Formula.
  • gunningFog(text: string): Returns the FOG index of the given text.
  • lix(text: string): Returns the LIX of the given text.
  • rix(text: string): Returns the RIX of the given text.
  • textStandard(text: string, floatOutput: boolean | null = null): Based upon all the above tests, returns the estimated school grade level required to understand the text.
  • textMedian(text: string): Returns the median grade level of the given text.