Socket
Book a DemoInstallSign in
Socket

spache-formula

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spache-formula

Formula to detect the grade level of text according to the (revised) Spache Readability Formula (1974)

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
2
Created
Source

spache-formula

Build Coverage Downloads Size

Formula to detect the grade level of text according to the (revised) Spache readability formula.

Contents

What is this?

This package exposes an algorithm to detect ease of reading of English texts.

When should I use this?

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”.

Install

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>

Use

import {spacheFormula} from 'spache-formula'

spacheFormula({word: 30, sentence: 2, unfamiliarWord: 6}) // => 4.114

spacheFormula({word: 30, sentence: 2}) // => 2.474

spacheFormula() // => NaN

API

This package exports the identifier spacheFormula. There is no default export.

spacheFormula(counts)

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

Counts from input document.

counts.sentence

Number of sentences (number, required).

counts.word

Number of words (number, required).

counts.unfamiliarWord

Number of unfamiliar words (number, default: 0).

Returns

Grade level associated with the document (number).

Types

This package is fully typed with TypeScript. It exports the additional type Counts.

Compatibility

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.

Contribute

Yes please! See How to Contribute to Open Source.

Security

This package is safe.

License

MIT © Titus Wormer

Keywords

revised

FAQs

Package last updated on 01 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts