Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

flesch

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flesch - npm Package Compare versions

Comparing version
0.1.0
to
1.0.0
+6
history.md
<!--remark setext-->
<!--lint disable no-multiple-toplevel-headings-->
1.0.0 / 2016-07-24
==================
# flesch [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov]
Formula to detect the grade level of text according to the
[Flesch Reading Ease][formula].
See [syllable][] for detecting syllables.
## Installation
[npm][npm-install]:
```bash
npm install flesch
```
## Usage
```js
var flesch = require('flesch');
/* For “The cat sat on the mat” (1 sentence, 6 words,
* 6 syllables). */
flesch({
sentence: 1,
word: 6,
syllable: 6
});
// 116.14500000000001
/* For “The Australian platypus is seemingly a hybrid of
* mammal and reptilian creature.” (1 sentence, 13 words,
* 26 syllables). */
flesch({
sentence: 1,
word: 13,
syllable: 26
});
// 24.440000000000026
```
## API
### `flesch(counts)`
Given an object containing the number of words (`word`), the number
of sentences (`sentence`), and the number of syllables (`syllable`)
in a document, returns the reading ease associated with the document.
Returned values are 120 (every sentence consisting of only two
one-syllable words), or lower (including negative values).
The values have the following semantics:
| Score | Semantics |
| :----------: | :-------------------------------------------------- |
| 90.0 – 100.0 | Easily understood by an average 11-year-old student |
| 60.0 – 70.0 | Easily understood by 13- to 15-year-old students |
| 0.0 – 30.0 | Best understood by university graduates |
## Related
* [`automated-readability`](https://github.com/wooorm/automated-readability)
— Uses character count instead of error-prone syllable parser;
* [`coleman-liau`](https://github.com/wooorm/coleman-liau)
— Uses letter count instead of an error-prone syllable parser;
* [`dale-chall-formula`](https://github.com/wooorm/dale-chall-formula)
— Uses a dictionary; suited for higher reading levels;
* [`flesch-kincaid`](https://github.com/wooorm/flesch-kincaid)
— Like `flesch`; returns U.S. grade levels;
* [`gunning-fog`](https://github.com/wooorm/gunning-fog)
— Uses syllable count; needs POS-tagging and NER;
* [`smog-formula`](https://github.com/wooorm/smog-formula)
— Like `gunning-fog-index`; without needing advanced NLP;
* [`spache-formula`](https://github.com/wooorm/spache-formula)
— Uses a dictionary; suited for lower reading levels.
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[travis-badge]: https://img.shields.io/travis/wooorm/flesch.svg
[travis]: https://travis-ci.org/wooorm/flesch
[codecov-badge]: https://img.shields.io/codecov/c/github/wooorm/flesch.svg
[codecov]: https://codecov.io/github/wooorm/flesch
[npm-install]: https://docs.npmjs.com/cli/install
[license]: LICENSE
[author]: http://wooorm.com
[formula]: http://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests#Flesch_Reading_Ease
[syllable]: https://github.com/wooorm/syllable
+23
-24

@@ -1,18 +0,24 @@

'use strict';
/**
* Constants.
* @author Titus Wormer
* @copyright 2014 Titus Wormer
* @license MIT
* @module flesch
* @fileoverview Detect ease of reading according to the
* the Flesch Reading Ease Formula.
*/
var SENTENCE_WEIGHT,
WORD_WEIGHT,
BASE;
'use strict';
SENTENCE_WEIGHT = 1.015;
WORD_WEIGHT = 84.6;
BASE = 206.835;
/* Expose. */
module.exports = exports = flesch;
/* Constants. */
var SENTENCE_WEIGHT = 1.015;
var WORD_WEIGHT = 84.6;
var BASE = 206.835;
/**
* Get the grade level of a given value according to the Flesch Reading Ease
* Formula. More information is available at WikiPedia:
* Get the grade level of a given value according to the
* Flesch Reading Ease Formula. More information is available
* at WikiPedia:
*

@@ -28,17 +34,10 @@ * http://en.wikipedia.org/wiki/

*/
function flesch(counts) {
if (!counts || !counts.sentence || !counts.word || !counts.syllable) {
return NaN;
}
if (!counts || !counts.sentence || !counts.word || !counts.syllable) {
return NaN;
}
return BASE -
SENTENCE_WEIGHT * (counts.word / counts.sentence) -
WORD_WEIGHT * (counts.syllable / counts.word);
return BASE -
(SENTENCE_WEIGHT * (counts.word / counts.sentence)) -
(WORD_WEIGHT * (counts.syllable / counts.word));
}
/**
* Export `flesch`.
*/
module.exports = flesch;
{
"name": "flesch",
"version": "0.1.0",
"version": "1.0.0",
"description": "Formula to detect the ease of reading a text according to Flesch Reading Ease (1975)",

@@ -11,23 +11,56 @@ "license": "MIT",

],
"repository": {
"type": "git",
"url": "https://github.com/wooorm/flesch.git"
},
"author": "Titus Wormer <tituswormer@gmail.com>",
"files": [
"index.js"
],
"repository": "https://github.com/wooorm/flesch",
"bugs": "https://github.com/wooorm/flesch/issues",
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)"
],
"dependencies": {},
"devDependencies": {
"eslint": "^0.9.0",
"istanbul": "^0.3.0",
"jscs": "^1.0.0",
"mocha": "^2.0.0"
"browserify": "^13.0.1",
"esmangle": "^1.0.1",
"is-nan": "^1.2.1",
"nyc": "^7.0.0",
"remark-cli": "^1.0.0",
"remark-comment-config": "^4.0.0",
"remark-github": "^5.0.0",
"remark-lint": "^4.0.0",
"remark-validate-links": "^4.0.0",
"tape": "^4.0.0",
"xo": "^0.16.0"
},
"scripts": {
"test": "node_modules/.bin/_mocha --reporter spec --check-leaks -u exports test.js",
"test-travis": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --check-leaks -u exports test.js",
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -- test.js",
"lint-api": "node_modules/.bin/eslint index.js",
"lint-test": "node_modules/.bin/eslint test.js --env mocha",
"lint-style": "node_modules/.bin/jscs index.js test.js --reporter=inline",
"lint": "npm run lint-api && npm run lint-test && npm run lint-style",
"make": "npm run lint && npm run coverage"
"build-md": "remark . --quiet --frail",
"build-bundle": "browserify index.js --bare -s flesch > flesch.js",
"build-mangle": "esmangle flesch.js > flesch.min.js",
"build": "npm run build-md && npm run build-bundle && npm run build-mangle",
"lint": "xo",
"test-api": "node test",
"test-coverage": "nyc --reporter lcov tape test.js",
"test": "npm run build && npm run lint && npm run test-coverage"
},
"xo": {
"space": true,
"ignores": [
"flesch.js",
"flesch.min.js"
]
},
"remarkConfig": {
"output": true,
"plugins": {
"comment-config": null,
"github": null,
"lint": {
"list-item-spacing": false
},
"validate-links": null
},
"settings": {
"bullet": "*"
}
}
}
# flesch [![Build Status](https://img.shields.io/travis/wooorm/flesch.svg?style=flat)](https://travis-ci.org/wooorm/flesch) [![Coverage Status](https://img.shields.io/coveralls/wooorm/flesch.svg?style=flat)](https://coveralls.io/r/wooorm/flesch?branch=master)
Formula to detect the ease of reading a text according to [Flesch Reading Ease](http://en.wikipedia.org/wiki/Flesch–Kincaid_readability_tests#Flesch_Reading_Ease).
See [syllable](https://github.com/wooorm/syllable) for detecting syllables.
## Installation
npm:
```sh
$ npm install flesch
```
Component:
```sh
$ component install wooorm/flesch
```
Bower:
```sh
$ bower install flesch
```
## Usage
```js
var flesch = require('flesch');
/**
* For “The cat sat on the mat” (1 sentence, 6 words,
* 6 syllables).
*/
flesch({
'sentence' : 1,
'word' : 6,
'syllable' : 6
});
// 116.14500000000001
/**
* For “The Australian platypus is seemingly a hybrid of
* mammal and reptilian creature.” (1 sentence, 13 words,
* 26 syllables).
*/
flesch({
'sentence' : 1,
'word' : 13,
'syllable' : 26
});
// 24.440000000000026
```
## API
### flesch(counts)
Given an object containing the number of words (`word`), the number of sentences (`sentence`), and the number of syllables (`syllable`) in a document, returns the reading ease associated with the document.
Returned values are 120 (every sentence consisting of only two one-syllable words), or lower (including negative values).
The values have the following semantics:
| Score | Semantics |
| :----------: | :-------------------------------------------------- |
| 90.0 – 100.0 | Easily understood by an average 11-year-old student |
| 60.0 – 70.0 | Easily understood by 13- to 15-year-old students |
| 0.0 – 30.0 | Best understood by university graduates |
## Related
- [automated-readability](https://github.com/wooorm/automated-readability) — Uses character count instead of an error-prone syllable parser;
- [coleman-liau](https://github.com/wooorm/coleman-liau) — Uses letter count instead of an error-prone syllable parser;
- [dale-chall-formula](https://github.com/wooorm/dale-chall-formula) — Uses a dictionary; suited for higher reading levels;
- [flesch-kincaid](https://github.com/wooorm/flesch-kincaid) — Like **flesch-formula**; returns U.S. grade levels;
- [gunning-fog](https://github.com/wooorm/gunning-fog) — Uses syllable count; hard to implement with a computer (needs POS-tagging and Named Entity Recognition);
- [smog-formula](https://github.com/wooorm/smog-formula) — Like **gunning-fog-index**; without the need for advanced NLP tasks;
- [spache-formula](https://github.com/wooorm/spache-formula) — Uses a dictionary; suited for lower reading levels.
## License
MIT © [Titus Wormer](http://wooorm.com)