Sorry, the diff of this file is not supported yet
+11
-9
@@ -1,17 +0,19 @@ | ||
| 'use strict'; | ||
| 'use strict' | ||
| module.exports = flesch; | ||
| module.exports = flesch | ||
| var SENTENCE_WEIGHT = 1.015; | ||
| var WORD_WEIGHT = 84.6; | ||
| var BASE = 206.835; | ||
| var sentenceWeight = 1.015 | ||
| var wordWeight = 84.6 | ||
| var base = 206.835 | ||
| function flesch(counts) { | ||
| if (!counts || !counts.sentence || !counts.word || !counts.syllable) { | ||
| return NaN; | ||
| return NaN | ||
| } | ||
| return BASE - | ||
| (SENTENCE_WEIGHT * (counts.word / counts.sentence)) - | ||
| (WORD_WEIGHT * (counts.syllable / counts.word)); | ||
| return ( | ||
| base - | ||
| sentenceWeight * (counts.word / counts.sentence) - | ||
| wordWeight * (counts.syllable / counts.word) | ||
| ) | ||
| } |
+28
-14
| { | ||
| "name": "flesch", | ||
| "version": "1.0.2", | ||
| "version": "1.0.3", | ||
| "description": "Formula to detect the ease of reading a text according to Flesch Reading Ease (1975)", | ||
@@ -22,23 +22,37 @@ "license": "MIT", | ||
| "devDependencies": { | ||
| "browserify": "^14.0.0", | ||
| "esmangle": "^1.0.1", | ||
| "browserify": "^16.0.0", | ||
| "is-nan": "^1.2.1", | ||
| "nyc": "^11.0.0", | ||
| "remark-cli": "^4.0.0", | ||
| "remark-preset-wooorm": "^3.0.0", | ||
| "nyc": "^13.0.0", | ||
| "prettier": "^1.14.2", | ||
| "remark-cli": "^5.0.0", | ||
| "remark-preset-wooorm": "^4.0.0", | ||
| "tape": "^4.0.0", | ||
| "xo": "^0.18.0" | ||
| "tinyify": "^2.4.3", | ||
| "xo": "^0.22.0" | ||
| }, | ||
| "scripts": { | ||
| "build-md": "remark . -qfo", | ||
| "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", | ||
| "format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
| "build-bundle": "browserify . -s flesch -o flesch.js", | ||
| "build-mangle": "browserify . -s flesch -p tinyify -o flesch.min.js", | ||
| "build": "npm run build-bundle && npm run build-mangle", | ||
| "test-api": "node test", | ||
| "test-coverage": "nyc --reporter lcov tape test.js", | ||
| "test": "npm run build && npm run lint && npm run test-coverage" | ||
| "test": "npm run format && npm run build && npm run test-coverage" | ||
| }, | ||
| "nyc": { | ||
| "check-coverage": true, | ||
| "lines": 100, | ||
| "functions": 100, | ||
| "branches": 100 | ||
| }, | ||
| "prettier": { | ||
| "tabWidth": 2, | ||
| "useTabs": false, | ||
| "singleQuote": true, | ||
| "bracketSpacing": false, | ||
| "semi": false, | ||
| "trailingComma": "none" | ||
| }, | ||
| "xo": { | ||
| "space": true, | ||
| "prettier": true, | ||
| "esnext": false, | ||
@@ -45,0 +59,0 @@ "ignores": [ |
+14
-26
@@ -19,22 +19,10 @@ # flesch [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
| ```js | ||
| var flesch = require('flesch'); | ||
| 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 cat sat on the mat” (1 sentence, 6 words, 6 syllables). | ||
| flesch({sentence: 1, word: 6, syllable: 6}) // => 116.14500... | ||
| /* For “The Australian platypus is seemingly a hybrid of | ||
| * mammal and reptilian creature.” (1 sentence, 12 words, | ||
| * 23 syllables). */ | ||
| flesch({ | ||
| sentence: 1, | ||
| word: 12, | ||
| syllable: 23 | ||
| }); | ||
| // 32.504999999999995 | ||
| // For “The Australian platypus is seemingly a hybrid of mammal and reptilian | ||
| // creature.” (1 sentence, 12 words, 23 syllables). | ||
| flesch({sentence: 1, word: 12, syllable: 23}) // => 32.50499... | ||
| ``` | ||
@@ -63,15 +51,15 @@ | ||
| * [`automated-readability`](https://github.com/wooorm/automated-readability) | ||
| * [`automated-readability`](https://github.com/words/automated-readability) | ||
| — Uses character count instead of error-prone syllable parser | ||
| * [`coleman-liau`](https://github.com/wooorm/coleman-liau) | ||
| * [`coleman-liau`](https://github.com/words/coleman-liau) | ||
| — Uses letter count instead of an error-prone syllable parser | ||
| * [`dale-chall-formula`](https://github.com/wooorm/dale-chall-formula) | ||
| * [`dale-chall-formula`](https://github.com/words/dale-chall-formula) | ||
| — Uses a dictionary, suited for higher reading levels | ||
| * [`flesch-kincaid`](https://github.com/wooorm/flesch-kincaid) | ||
| * [`flesch-kincaid`](https://github.com/words/flesch-kincaid) | ||
| — Like `flesch`, returns U.S. grade levels | ||
| * [`gunning-fog`](https://github.com/wooorm/gunning-fog) | ||
| * [`gunning-fog`](https://github.com/words/gunning-fog) | ||
| — Uses syllable count, needs POS-tagging and NER | ||
| * [`smog-formula`](https://github.com/wooorm/smog-formula) | ||
| * [`smog-formula`](https://github.com/words/smog-formula) | ||
| — Like `gunning-fog-index`, without needing advanced NLP | ||
| * [`spache-formula`](https://github.com/wooorm/spache-formula) | ||
| * [`spache-formula`](https://github.com/words/spache-formula) | ||
| — Uses a dictionary, suited for lower reading levels | ||
@@ -95,3 +83,3 @@ | ||
| [license]: LICENSE | ||
| [license]: license | ||
@@ -98,0 +86,0 @@ [author]: http://wooorm.com |
-22
| (The MIT License) | ||
| Copyright (c) 2014 Titus Wormer <tituswormer@gmail.com> | ||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| 'Software'), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
| IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
| CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
| TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
| SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
6018
4.42%15
15.38%9
12.5%88
-12%