Coder Social home page Coder Social logo

retext-readability's Introduction

retext-readability Build Status Coverage Status

Check readability with retext. Applies Dale—Chall, Automated Readability, Coleman-Liau, Flesch, Gunning-Fog, SMOG, and Spache.

Installation

npm:

npm install retext-readability

Usage

var retext = require('retext');
var readability = require('retext-readability');
var report = require('vfile-reporter');

var doc = [
  'The cat sat on the mat',
  '',
  'The constellation also contains an isolated neutron ',
  'star—Calvera—and H1504+65, the hottest white dwarf yet ',
  'discovered, with a surface temperature of 200,000 kelvin',
  ''
].join('\n');

By default, the target age is 16:

retext()
  .use(readability)
  .process(doc, function (err, file) {
    console.log(report(err || file));
  });

Yields:

   3:1-5:57  warning  Hard to read sentence (confidence: 4/7)  retext-readability

⚠ 1 warning

...but ages can be set, for example, to 8:

retext()
  .use(readability, {age: 6})
  .process(doc, function (err, file) {
    console.log(report(err || file));
  });

Yields:

   1:1-1:23  warning  Hard to read sentence (confidence: 4/7)  retext-readability
   3:1-5:57  warning  Hard to read sentence (confidence: 7/7)  retext-readability

⚠ 1 warning

API

retext().use(readability[, options])

Detect possibly hard to read sentences.

options
  • age (number, default: 16) — Target age group. Note that the different algorithms provide varying results, so your milage may vary with people actually that age. 😉
  • threshold (number, default: 4 / 7) — By default, 4 out of the 7 algorithms need to agree that a sentence is higher than the target age and whether it should be warned about. This can be modified by passing in a new threshold.
  • minWords (number, default: 5) — Minimum number of words a sentence should have when warning. Most algorithms are designed to take a large sample of sentences to detect the body’s reading level. This plug-in, however, works on a per-sentence basis. This makes the results quite skewered when said sentence has, for example, a few long words or some unknown ones.

License

MIT © Titus Wormer

retext-readability's People

Contributors

wooorm avatar greenkeeperio-bot avatar dunckr avatar localjo avatar nodatall avatar

Watchers

James Cloos avatar James Drew avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.