├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin └── rousseau.js ├── lib ├── cache.js ├── en │ ├── adverbs.js │ ├── data │ │ ├── adverbs.js │ │ ├── passive.js │ │ ├── simpler.js │ │ └── weasel.js │ ├── index.js │ ├── lexical-illusion.js │ ├── passive.js │ ├── readibility.js │ ├── sentence-end.js │ ├── sentence-start.js │ ├── sentence-uppercase.js │ ├── simplicity.js │ ├── so.js │ └── weasel.js ├── index.js ├── languages.js ├── levels.js ├── tokenize.js └── utils │ └── html.js ├── package.json ├── preview.jpg └── test ├── api.js ├── en.js ├── fixtures └── test.html └── helper.js /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # Compiled binary addons (http://nodejs.org/api/addons.html) 20 | build/Release 21 | 22 | # Dependency directory 23 | # Deployed apps should consider commenting this line out: 24 | # see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git 25 | node_modules 26 | 27 | # vim swapfile 28 | *.swp 29 | 30 | dist 31 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.11" 4 | - "0.10" 5 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute 2 | 3 | The project is run on Github, in the typical free software way - we'd love to accept your patches and contributions to this project. 4 | 5 | Prerequisites: familiarity with [GitHub PRs](https://help.github.com/articles/using-pull-requests) (pull requests) and issues. 6 | Knowledge of Javascript. 7 | 8 | This community seeks the following types of contributions: 9 | 10 | - **ideas**: participate in an Issues thread or start your own to have your voice 11 | heard. 12 | - **new languages**: submit a PR to add your language 13 | - **new checks** or improve existing ones 14 | - **copy editing**: fix typos, clarify language, and generally improve the quality 15 | of the content 16 | - **documentation**: help keep the README easy to read and understadable with consistent formatting 17 | 18 | ## Add a new check 19 | 20 | 1. Describe your check in the `README.md`. 21 | 2. Create a file named with the `ID` for the new check, example: `end-with-right.js`. 22 | 3. Include it in the `/index.js`. 23 | 4. Add some unit tests corresponding to yoru check. 24 | 5. Use the `tokenizer` to return suggestions, example to signal sentences ending with "Right?": 25 | 26 | ```js 27 | var levels = require("../levels"); 28 | var tokenize = require("../tokenize"); 29 | 30 | module.exports = tokenize.check( 31 | // Tokenize as sentences 32 | tokenize.sentences(), 33 | 34 | // Match the ones ending with "right?" 35 | tokenize.re(/\bright\b\s\?$/i), 36 | 37 | // Output 38 | tokenize.define({ 39 | level: levels.WARNING, 40 | message: "omit 'right?' at the end of sentences" 41 | }) 42 | ); 43 | ``` 44 | 45 | ## Add a new language 46 | 47 | 1. Create a folder named with the [ISO 639-1](http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) language code. 48 | 2. Add your language in the `lib/languages.js` file. 49 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2014 FriendCode Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ![Rousseau](./preview.jpg) 3 | 4 | [![Build Status](https://travis-ci.org/GitbookIO/rousseau.png?branch=master)](https://travis-ci.org/GitbookIO/rousseau) 5 | [![NPM version](https://badge.fury.io/js/rousseau.svg)](http://badge.fury.io/js/rousseau) 6 | 7 | Rousseau is a lightweight proofreader written in Javascript, it can be used in Node.JS, in the command line and in the browser. 8 | 9 | ### Installation 10 | 11 | ``` 12 | $ npm install rousseau 13 | ``` 14 | 15 | ### API 16 | 17 | ```js 18 | var rousseau = require("rousseau"); 19 | 20 | rousseau('So the cat was stolen.', function(err, results) { 21 | ... 22 | }); 23 | ``` 24 | 25 | `results` is an array of object like: 26 | 27 | ```js 28 | { 29 | // Type of check that output this suggestion 30 | type: "so", 31 | 32 | // Level of importance 33 | // "suggestion", "warning", "error" 34 | level: "warning", 35 | 36 | // Index in the text 37 | index: 10, 38 | 39 | // Size of the section in the text 40 | offset: 2, 41 | 42 | // Message to describe the suggestion 43 | message: "omit 'So' from the beginning of sentences", 44 | 45 | // Replacements suggestion 46 | replacements: [ 47 | { 48 | value: "" 49 | } 50 | ] 51 | } 52 | ``` 53 | 54 | ### Checks 55 | 56 | You can disable any combination of the following by providing a key with value `false` as option `checks` to `rousseau`. 57 | 58 | ##### English 59 | 60 | | ID | Description | 61 | | ----- | --------------- | 62 | | `passive` | Checks for passive voice | 63 | | `lexical-illusion` | Checks for lexical illusions – cases where a word is repeated. | 64 | | `so` | Checks for `so` at the beginning of the sentence. | 65 | | `adverbs` | Checks for adverbs that can weaken meaning: really, very, extremely, etc. | 66 | | `readibility` | Checks for readibility of sentences. | 67 | | `simplicity` | Checks for simpler expressions | 68 | | `weasel` | Checks for "weasel words." | 69 | | `sentence:start` | Checks that sentence is preceded by a space | 70 | | `sentence:end` | Checks that there is no space between a sentence and its ending punctuation | 71 | | `sentence:uppercase` | Checks that sentences are starting with uppercase letter | 72 | 73 | 74 | ### Extend Rousseau 75 | 76 | Example: Extend rousseau with a Spellchecker. 77 | 78 | ```js 79 | rousseau("Some text", { 80 | checks: { 81 | spelling: rousseau.tokenize.check([ 82 | rousseau.tokenize.words(), 83 | rousseau.filter(function(word) { 84 | return wordIsValid(word); 85 | }), 86 | rousseau.define({ 87 | level: rousseau.levels.ERROR, 88 | message: "Spelling error" 89 | }) 90 | ]) 91 | } 92 | }, function(err, results) { 93 | ... 94 | }) 95 | 96 | ``` 97 | 98 | ### Cache 99 | 100 | Rousseau use an internal cache for certain operations (tokenization, spellchecking, ...); this cache can be configured using the option `cache`: 101 | 102 | ```js 103 | rousseau('So the cat was stolen.', { 104 | cache: 100 // A maximum of 100 elements will be stored in the memory cache 105 | }, function(err, results) { 106 | ... 107 | }); 108 | ``` 109 | 110 | ### Contributing 111 | 112 | We'd love to accept your patches and contributions to improve Rousseau (supported languages, checks, ...). Learn more about how to contribute in [CONTRIBUTING.md](./CONTRIBUTING.md). 113 | -------------------------------------------------------------------------------- /bin/rousseau.js: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env node 2 | 3 | var _ = require('lodash'); 4 | var color = require('bash-color'); 5 | var Table = require('cli-table'); 6 | var findLineColumn = require('find-line-column'); 7 | 8 | var fs = require('fs'); 9 | var path = require('path'); 10 | 11 | var rousseau = require('../lib'); 12 | var tokenizeHTML = require('tokenize-htmltext'); 13 | 14 | // Colors for levels 15 | var LEVELS = { 16 | critical: color.red, 17 | error: color.red, 18 | warning: color.yellow, 19 | suggestion: color.cyan 20 | }; 21 | 22 | // By default read input stream 23 | var input = process.argv[2]; 24 | 25 | // Original file content 26 | var fileContent = ""; 27 | 28 | // Parse input file 29 | function parseFile(input) { 30 | fileContent = fs.readFileSync(input, { encoding: "utf-8" }); 31 | var ext = path.extname(input); 32 | 33 | if (ext == '.html') return tokenizeHTML(fileContent); 34 | 35 | return fileContent; 36 | } 37 | 38 | if (!input) { 39 | console.log("Need at least one argument, ex: rousseau ./my.txt"); 40 | process.exit(1); 41 | } else { 42 | input = path.resolve(process.cwd(), input); 43 | } 44 | 45 | // Read and lint file 46 | var content = parseFile(input); 47 | 48 | rousseau(content, function(err, results) { 49 | if (err) { 50 | console.log(color.red("Error: "+(err.stack || err))); 51 | return process.exit(1); 52 | } 53 | 54 | var levels = {}; 55 | var table = new Table({ 56 | chars: { 'top': '' , 'top-mid': '' , 'top-left': '' , 'top-right': '' 57 | , 'bottom': '' , 'bottom-mid': '' , 'bottom-left': '' , 'bottom-right': '' 58 | , 'left': '' , 'left-mid': '' , 'mid': '' , 'mid-mid': '' 59 | , 'right': '' , 'right-mid': '' , 'middle': ' ' }, 60 | style: { 'padding-left': 0, 'padding-right': 0 } 61 | }); 62 | 63 | if (results.length > 0) { 64 | console.log("Results for '"+color.wrap(input, "white", "underline")+"':"); 65 | console.log(""); 66 | 67 | _.each(results, function(result) { 68 | var color = LEVELS[result.level]; 69 | var startPos = findLineColumn(fileContent, result.index); 70 | var endPos = findLineColumn(fileContent, result.index + result.offset); 71 | 72 | levels[result.level] = (levels[result.level] || 0) + 1; 73 | 74 | table.push([ 75 | " ", startPos.line+":"+startPos.col, 76 | endPos.line+":"+endPos.col, 77 | color("["+result.level+"]"), 78 | result.message 79 | ]); 80 | }); 81 | 82 | console.log(table.toString()); 83 | console.log(""); 84 | console.log(color.cyan(results.length+" Problems ("+(levels.error || 0)+" errors, "+(levels.warning || 0)+" warnings)")); 85 | } else { 86 | console.log(color.green("All good!")) 87 | } 88 | }); 89 | -------------------------------------------------------------------------------- /lib/cache.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | var crc = require('crc'); 3 | var LRUCache = require("simple-lru-cache"); 4 | 5 | var lru = undefined; 6 | var cacheSize = 0; 7 | 8 | function setLimit(limit) { 9 | if (limit == cacheSize) return; 10 | cacheSize = limit; 11 | if (limit > 0) lru = new LRUCache({ "maxSize": limit }); 12 | else lru = null; 13 | } 14 | 15 | function cacheNamespace(namespace) { 16 | var _key = function(key) { 17 | return namespace+":"+crc.crc32(key).toString(16); 18 | } 19 | 20 | var _cache = { 21 | get: function(key) { 22 | if (!lru) return undefined; 23 | var val = lru.get(_key(key)); 24 | return val? JSON.parse(val) : undefined; 25 | }, 26 | set: function(key, value) { 27 | if (!lru) return undefined; 28 | return lru.set(_key(key), JSON.stringify(value)); 29 | }, 30 | 31 | // Change namespacing 32 | rename: function(name) { 33 | namespace = name; 34 | }, 35 | 36 | // Return a sub-namespace 37 | namespace: function(name) { 38 | return cacheNamespace(namespace+":"+name); 39 | }, 40 | 41 | // Set limit 42 | setLimit: setLimit 43 | }; 44 | 45 | return _cache; 46 | } 47 | 48 | 49 | module.exports = cacheNamespace(""); 50 | -------------------------------------------------------------------------------- /lib/en/adverbs.js: -------------------------------------------------------------------------------- 1 | var tokenize = require("../tokenize"); 2 | var levels = require("../levels"); 3 | var adverbs = require("./data/adverbs"); 4 | 5 | var re = new RegExp('\\b(' + adverbs.join('|') + ')(y)\\b', 'gi'); 6 | 7 | module.exports = tokenize.check( 8 | tokenize.re(re), 9 | tokenize.define({ 10 | message: 'adverbs can weaken meaning' 11 | }) 12 | ); 13 | module.exports.level = levels.WARNING; 14 | -------------------------------------------------------------------------------- /lib/en/data/adverbs.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | 'absolutel', 3 | 'accidentall', 4 | 'additionall', 5 | 'allegedl', 6 | 'alternativel', 7 | 'angril', 8 | 'anxiousl', 9 | 'approximatel', 10 | 'awkwardl', 11 | 'badl', 12 | 'barel', 13 | 'beautifull', 14 | 'blindl', 15 | 'boldl', 16 | 'bravel', 17 | 'brightl', 18 | 'briskl', 19 | 'bristl', 20 | 'bubbl', 21 | 'busil', 22 | 'calml', 23 | 'carefull', 24 | 'carelessl', 25 | 'cautiousl', 26 | 'cheerfull', 27 | 'clearl', 28 | 'closel', 29 | 'coldl', 30 | 'completel', 31 | 'consequentl', 32 | 'correctl', 33 | 'courageousl', 34 | 'crinkl', 35 | 'cruell', 36 | 'crumbl', 37 | 'cuddl', 38 | 'currentl', 39 | 'dail', 40 | 'daringl', 41 | 'deadl', 42 | 'definitel', 43 | 'deliberatel', 44 | 'doubtfull', 45 | 'dumbl', 46 | 'eagerl', 47 | 'earl', 48 | 'easil', 49 | 'elegantl', 50 | 'enormousl', 51 | 'enthusiasticall', 52 | 'equall', 53 | 'especiall', 54 | 'eventuall', 55 | 'exactl', 56 | 'exceedingl', 57 | 'exclusivel', 58 | 'extremel', 59 | 'fairl', 60 | 'faithfull', 61 | 'fatall', 62 | 'fiercel', 63 | 'finall', 64 | 'fondl', 65 | 'foolishl', 66 | 'fortunatel', 67 | 'frankl', 68 | 'franticall', 69 | 'generousl', 70 | 'gentl', 71 | 'giggl', 72 | 'gladl', 73 | 'gracefull', 74 | 'greedil', 75 | 'happil', 76 | 'hardl', 77 | 'hastil', 78 | 'healthil', 79 | 'heartil', 80 | 'honestl', 81 | 'hourl', 82 | 'hungril', 83 | 'hurriedl', 84 | 'immediatel', 85 | 'impatientl', 86 | 'inadequatel', 87 | 'ingeniousl', 88 | 'innocentl', 89 | 'inquisitivel', 90 | 'interestingl', 91 | 'irritabl', 92 | 'jiggl', 93 | 'joyousl', 94 | 'justl', 95 | 'kindl', 96 | 'largel', 97 | 'latel', 98 | 'lazil', 99 | 'likel', 100 | 'literall', 101 | 'lonel', 102 | 'loosel', 103 | 'loudl', 104 | 'loudl', 105 | 'luckil', 106 | 'madl', 107 | 'man', 108 | 'mentall', 109 | 'mildl', 110 | 'monthl', 111 | 'mortall', 112 | 'mostl', 113 | 'mysteriousl', 114 | 'neatl', 115 | 'nervousl', 116 | 'nightl', 117 | 'noisil', 118 | 'normall', 119 | 'obedientl', 120 | 'occasionall', 121 | 'onl', 122 | 'openl', 123 | 'painfull', 124 | 'particularl', 125 | 'patientl', 126 | 'perfectl', 127 | 'politel', 128 | 'poorl', 129 | 'powerfull', 130 | 'presumabl', 131 | 'previousl', 132 | 'promptl', 133 | 'punctuall', 134 | 'quarterl', 135 | 'quickl', 136 | 'quietl', 137 | 'rapidl', 138 | 'rarel', 139 | 'reall', 140 | 'recentl', 141 | 'recklessl', 142 | 'regularl', 143 | 'relativel', 144 | 'reluctantl', 145 | 'remarkabl', 146 | 'repeatedl', 147 | 'rightfull', 148 | 'roughl', 149 | 'rudel', 150 | 'sadl', 151 | 'safel', 152 | 'selfishl', 153 | 'sensibl', 154 | 'seriousl', 155 | 'sharpl', 156 | 'shortl', 157 | 'shyl', 158 | 'significantl', 159 | 'silentl', 160 | 'simpl', 161 | 'sleepil', 162 | 'slowl', 163 | 'smartl', 164 | 'smell', 165 | 'smoothl', 166 | 'softl', 167 | 'solemnl', 168 | 'sparkl', 169 | 'speedil', 170 | 'stealthil', 171 | 'sternl', 172 | 'stupidl', 173 | 'substantiall', 174 | 'successfull', 175 | 'suddenl', 176 | 'surprisingl', 177 | 'suspiciousl', 178 | 'swiftl', 179 | 'tenderl', 180 | 'tensel', 181 | 'thoughtfull', 182 | 'tightl', 183 | 'timel', 184 | 'truthfull', 185 | 'unexpectedl', 186 | 'unfortunatel', 187 | 'usuall', 188 | 'ver', 189 | 'victoriousl', 190 | 'violentl', 191 | 'vivaciousl', 192 | 'warml', 193 | 'waverl', 194 | 'weakl', 195 | 'wearil', 196 | 'weekl', 197 | 'wildl', 198 | 'wisel', 199 | 'worldl', 200 | 'wrinkl', 201 | 'yearl' 202 | ]; 203 | -------------------------------------------------------------------------------- /lib/en/data/passive.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | list: [ 3 | { 4 | value: "awoken", 5 | replace: "awoke" 6 | }, { 7 | value: "beaten", 8 | replace: "beat" 9 | }, { 10 | value: "begun", 11 | replace: "began" 12 | }, { 13 | value: "bent", 14 | replace: "bent" 15 | }, { 16 | value: "bitten", 17 | replace: "bit" 18 | }, { 19 | value: "bled", 20 | replace: "bled" 21 | }, { 22 | value: "blown", 23 | replace: "blew" 24 | }, { 25 | value: "broken", 26 | replace: "broke" 27 | }, { 28 | value: "brought", 29 | replace: "brought" 30 | }, { 31 | value: "built", 32 | replace: "built" 33 | }, { 34 | value: "bought", 35 | replace: "bought" 36 | }, { 37 | value: "caught", 38 | replace: "caught" 39 | }, { 40 | value: "chosen", 41 | replace: "chose" 42 | }, { 43 | value: "cut", 44 | replace: "cut" 45 | }, { 46 | value: "dealt", 47 | replace: "dealt" 48 | }, { 49 | value: "done", 50 | replace: "did" 51 | }, { 52 | value: "drawn", 53 | replace: "drew" 54 | }, { 55 | value: "driven", 56 | replace: "drove" 57 | }, { 58 | value: "eaten", 59 | replace: "ate" 60 | }, { 61 | value: "fed", 62 | replace: "fed" 63 | }, { 64 | value: "felt", 65 | replace: "felt" 66 | }, { 67 | value: "fought", 68 | replace: "fought" 69 | }, { 70 | value: "found", 71 | replace: "found" 72 | }, { 73 | value: "forbidden", 74 | replace: "forbade" 75 | }, { 76 | value: "forgotten", 77 | replace: "forgot" 78 | }, { 79 | value: "forgiven", 80 | replace: "forgave" 81 | }, { 82 | value: "frozen", 83 | replace: "froze" 84 | }, { 85 | value: "gotten", 86 | replace: "got" 87 | }, { 88 | value: "given", 89 | replace: "gave" 90 | }, { 91 | value: "ground", 92 | replace: "ground" 93 | }, { 94 | value: "ground", 95 | replace: "ground, grinded" 96 | }, { 97 | value: "hung", 98 | replace: "hung" 99 | }, { 100 | value: "heard", 101 | replace: "heard" 102 | }, { 103 | value: "hidden", 104 | replace: "hid" 105 | }, { 106 | value: "hit", 107 | replace: "hit" 108 | }, { 109 | value: "held", 110 | replace: "held" 111 | }, { 112 | value: "hurt", 113 | replace: "hurt" 114 | }, { 115 | value: "kept", 116 | replace: "kept" 117 | }, { 118 | value: "known", 119 | replace: "knew" 120 | }, { 121 | value: "laid", 122 | replace: "laid" 123 | }, { 124 | value: "led", 125 | replace: "led" 126 | }, { 127 | value: "left", 128 | replace: "left" 129 | }, { 130 | value: "let", 131 | replace: "let" 132 | }, { 133 | value: "lost", 134 | replace: "lost" 135 | }, { 136 | value: "made", 137 | replace: "made" 138 | }, { 139 | value: "meant", 140 | replace: "meant" 141 | }, { 142 | value: "met", 143 | replace: "met" 144 | }, { 145 | value: "paid", 146 | replace: "paid" 147 | }, { 148 | value: "proven", 149 | replace: "proved" 150 | }, { 151 | value: "put", 152 | replace: "put" 153 | }, { 154 | value: "read", 155 | replace: "read" 156 | }, { 157 | value: "ridden", 158 | replace: "rode" 159 | }, { 160 | value: "rung", 161 | replace: "rang" 162 | }, { 163 | value: "run", 164 | replace: "ran" 165 | }, { 166 | value: "said", 167 | replace: "said" 168 | }, { 169 | value: "seen", 170 | replace: "saw" 171 | }, { 172 | value: "sold", 173 | replace: "sold" 174 | }, { 175 | value: "sent", 176 | replace: "sent" 177 | }, { 178 | value: "shaken", 179 | replace: "shook" 180 | }, { 181 | value: "shaved", 182 | replace: "shaved" 183 | }, { 184 | value: "shot", 185 | replace: "shot" 186 | }, { 187 | value: "shown", 188 | replace: "showed" 189 | }, { 190 | value: "shut", 191 | replace: "shut" 192 | }, { 193 | value: "sung", 194 | replace: "sung" 195 | }, { 196 | value: "sunk", 197 | replace: "sunk" 198 | }, { 199 | value: "slain", 200 | replace: "slew" 201 | }, { 202 | value: "slid", 203 | replace: "slid" 204 | }, { 205 | value: "spoken", 206 | replace: "spoke" 207 | }, { 208 | value: "spent", 209 | replace: "spent" 210 | }, { 211 | value: "spun", 212 | replace: "spun" 213 | }, { 214 | value: "split", 215 | replace: "split" 216 | }, { 217 | value: "spread", 218 | replace: "spread" 219 | }, { 220 | value: "stolen", 221 | replace: "stole" 222 | }, { 223 | value: "struck", 224 | replace: "struck" 225 | }, { 226 | value: "swept", 227 | replace: "swept" 228 | }, { 229 | value: "swung", 230 | replace: "swung" 231 | }, { 232 | value: "taken", 233 | replace: "took" 234 | }, { 235 | value: "taught", 236 | replace: "taught" 237 | }, { 238 | value: "torn", 239 | replace: "tore" 240 | }, { 241 | value: "told", 242 | replace: "told" 243 | }, { 244 | value: "thought", 245 | replace: "thought" 246 | }, { 247 | value: "thrown", 248 | replace: "threw" 249 | }, { 250 | value: "undergone", 251 | replace: "underwent" 252 | }, { 253 | value: "understood", 254 | replace: "understood" 255 | }, { 256 | value: "upset", 257 | replace: "upset" 258 | }, { 259 | value: "woken", 260 | replace: "woke" 261 | }, { 262 | value: "worn", 263 | replace: "wore" 264 | }, { 265 | value: "won", 266 | replace: "won" 267 | }, { 268 | value: "withdrawn", 269 | replace: "withdrew" 270 | }, { 271 | value: "written", 272 | replace: "wrote" 273 | } 274 | ] 275 | } 276 | -------------------------------------------------------------------------------- /lib/en/data/simpler.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | { 3 | value: "a number of", 4 | replace: "Many, some" 5 | }, { 6 | value: "abundance", 7 | replace: "Enough, plenty" 8 | }, { 9 | value: "accede to", 10 | replace: "Allow, agree to" 11 | }, { 12 | value: "accelerate", 13 | replace: "Speed up" 14 | }, { 15 | value: "accentuate", 16 | replace: "Stress" 17 | }, { 18 | value: "accompany", 19 | replace: "Go with, with" 20 | }, { 21 | value: "accomplish", 22 | replace: "Do" 23 | }, { 24 | value: "accorded", 25 | replace: "Given" 26 | }, { 27 | value: "accrue", 28 | replace: "Add, gain" 29 | }, { 30 | value: "acquiesce", 31 | replace: "Agree" 32 | }, { 33 | value: "acquire", 34 | replace: "Get" 35 | }, { 36 | value: "additional", 37 | replace: "More, extra" 38 | }, { 39 | value: "adjacent to", 40 | replace: "Next to" 41 | }, { 42 | value: "adjustment", 43 | replace: "Change" 44 | }, { 45 | value: "admissible", 46 | replace: "Allowed, accepted" 47 | }, { 48 | value: "advantageous", 49 | replace: "Helpful" 50 | }, { 51 | value: "adversely impact", 52 | replace: "Hurt" 53 | }, { 54 | value: "advise", 55 | replace: "Tell" 56 | }, { 57 | value: "aforementioned", 58 | replace: "Remove" 59 | }, { 60 | value: "aggregate", 61 | replace: "Total, add" 62 | }, { 63 | value: "aircraft", 64 | replace: "Plane" 65 | }, { 66 | value: "all of", 67 | replace: "All" 68 | }, { 69 | value: "alleviate", 70 | replace: "Ease, reduce" 71 | }, { 72 | value: "allocate", 73 | replace: "Divide" 74 | }, { 75 | value: "along the lines of", 76 | replace: "Like, as in" 77 | }, { 78 | value: "already existing", 79 | replace: "Existing" 80 | }, { 81 | value: "alternatively", 82 | replace: "Or" 83 | }, { 84 | value: "ameliorate", 85 | replace: "Improve, help" 86 | }, { 87 | value: "anticipate", 88 | replace: "Expect" 89 | }, { 90 | value: "apparent", 91 | replace: "Clear, plain" 92 | }, { 93 | value: "appreciable", 94 | replace: "Many" 95 | }, { 96 | value: "as a means of", 97 | replace: "To" 98 | }, { 99 | value: "as of yet", 100 | replace: "Yet" 101 | }, { 102 | value: "as to", 103 | replace: "on, about" 104 | }, { 105 | value: "as yet", 106 | replace: "Yet" 107 | }, { 108 | value: "ascertain", 109 | replace: "Find out, learn" 110 | }, { 111 | value: "assistance", 112 | replace: "Help" 113 | }, { 114 | value: "at this time", 115 | replace: "Now" 116 | }, { 117 | value: "attain", 118 | replace: "Meet" 119 | }, { 120 | value: "attributable to", 121 | replace: "Because" 122 | }, { 123 | value: "authorize", 124 | replace: "Allow, let" 125 | }, { 126 | value: "because of the fact that", 127 | replace: "because" 128 | }, { 129 | value: "belated", 130 | replace: "late" 131 | }, { 132 | value: "benefit from", 133 | replace: "enjoy" 134 | }, { 135 | value: "bestow", 136 | replace: "give, award" 137 | }, { 138 | value: "by virtue of", 139 | replace: "by, under" 140 | }, { 141 | value: "cease", 142 | replace: "stop" 143 | }, { 144 | value: "close proximity", 145 | replace: "near" 146 | }, { 147 | value: "commence", 148 | replace: "Begin or start" 149 | }, { 150 | value: "comply with", 151 | replace: "follow" 152 | }, { 153 | value: "concerning", 154 | replace: "about, on" 155 | }, { 156 | value: "consequently", 157 | replace: "so" 158 | }, { 159 | value: "consolidate", 160 | replace: "join, merge" 161 | }, { 162 | value: "constitutes", 163 | replace: "is, forms, makes up" 164 | }, { 165 | value: "demonstrate", 166 | replace: "prove, show" 167 | }, { 168 | value: "depart", 169 | replace: "leave, go" 170 | }, { 171 | value: "designate", 172 | replace: "choose, name" 173 | }, { 174 | value: "discontinue", 175 | replace: "drop, stop" 176 | }, { 177 | value: "due to the fact that", 178 | replace: "because, since" 179 | }, { 180 | value: "each and every", 181 | replace: "Each" 182 | }, { 183 | value: "economical", 184 | replace: "cheap" 185 | }, { 186 | value: "eliminate", 187 | replace: "cut, drop, end" 188 | }, { 189 | value: "elucidate", 190 | replace: "explain" 191 | }, { 192 | value: "employ", 193 | replace: "use" 194 | }, { 195 | value: "endeavor", 196 | replace: "try" 197 | }, { 198 | value: "enumerate", 199 | replace: "count" 200 | }, { 201 | value: "equitable", 202 | replace: "fair" 203 | }, { 204 | value: "equivalent", 205 | replace: "equal" 206 | }, { 207 | value: "evaluate", 208 | replace: "test, check" 209 | }, { 210 | value: "evidenced", 211 | replace: "showed" 212 | }, { 213 | value: "exclusively", 214 | replace: "only" 215 | }, { 216 | value: "expedite", 217 | replace: "hurry" 218 | }, { 219 | value: "expend", 220 | replace: "spend" 221 | }, { 222 | value: "expiration", 223 | replace: "end" 224 | }, { 225 | value: "facilitate", 226 | replace: "ease, help" 227 | }, { 228 | value: "factual evidence", 229 | replace: "facts, evidence" 230 | }, { 231 | value: "feasible", 232 | replace: "workable" 233 | }, { 234 | value: "finalize", 235 | replace: "complete, finish" 236 | }, { 237 | value: "first and foremost", 238 | replace: "first" 239 | }, { 240 | value: "for the purpose of,", 241 | replace: "to" 242 | }, { 243 | value: "forfeit", 244 | replace: "lose, give up" 245 | }, { 246 | value: "formulate", 247 | replace: "plan" 248 | }, { 249 | value: "honest truth", 250 | replace: "truth" 251 | }, { 252 | value: "however", 253 | replace: "but, yet" 254 | }, { 255 | value: "if and when", 256 | replace: "use either word; not both" 257 | }, { 258 | value: "impacted", 259 | replace: "affected, harmed, changed" 260 | }, { 261 | value: "implement", 262 | replace: "install, put in place; tool" 263 | }, { 264 | value: "in a timely manner", 265 | replace: "on time" 266 | }, { 267 | value: "in accordance with", 268 | replace: "by, under" 269 | }, { 270 | value: "in addition", 271 | replace: "also, besides, too" 272 | }, { 273 | value: "in all likelihood", 274 | replace: "probably" 275 | }, { 276 | value: "in an effort to", 277 | replace: "to" 278 | }, { 279 | value: "in between", 280 | replace: "between" 281 | }, { 282 | value: "in excess of", 283 | replace: "more than" 284 | }, { 285 | value: "in lieu of", 286 | replace: "instead" 287 | }, { 288 | value: "in light of the fact that", 289 | replace: "because" 290 | }, { 291 | value: "in many cases", 292 | replace: "often" 293 | }, { 294 | value: "in order to", 295 | replace: "to" 296 | }, { 297 | value: "in regard to", 298 | replace: "about, concerning, on" 299 | }, { 300 | value: "in some instances ", 301 | replace: "sometimes" 302 | }, { 303 | value: "in terms of", 304 | replace: "omit; for, as, with" 305 | }, { 306 | value: "in the near future", 307 | replace: "soon" 308 | }, { 309 | value: "in the process of", 310 | replace: "omit" 311 | }, { 312 | value: "inception", 313 | replace: "start" 314 | }, { 315 | value: "incumbent upon", 316 | replace: "must" 317 | }, { 318 | value: "indicate", 319 | replace: "say, state, or show" 320 | }, { 321 | value: "indication", 322 | replace: "sign" 323 | }, { 324 | value: "initiate", 325 | replace: "start" 326 | }, { 327 | value: "is applicable to", 328 | replace: "applies to" 329 | }, { 330 | value: "is authorized to", 331 | replace: "may" 332 | }, { 333 | value: "is responsible for", 334 | replace: "handles" 335 | }, { 336 | value: "it is essential", 337 | replace: "must, need to" 338 | }, { 339 | value: "magnitude", 340 | replace: "size" 341 | }, { 342 | value: "maximum", 343 | replace: "greatest, largest, most" 344 | }, { 345 | value: "methodology", 346 | replace: "method" 347 | }, { 348 | value: "minimize", 349 | replace: "cut" 350 | }, { 351 | value: "minimum", 352 | replace: "least, smallest, small" 353 | }, { 354 | value: "modify", 355 | replace: "change" 356 | }, { 357 | value: "monitor", 358 | replace: "check, watch, track" 359 | }, { 360 | value: "multiple", 361 | replace: "many" 362 | }, { 363 | value: "necessitate", 364 | replace: "cause, need" 365 | }, { 366 | value: "nevertheless", 367 | replace: "still, besides, even so" 368 | }, { 369 | value: "not certain", 370 | replace: "uncertain" 371 | }, { 372 | value: "not many", 373 | replace: "few" 374 | }, { 375 | value: "not often", 376 | replace: "rarely" 377 | }, { 378 | value: "not unless", 379 | replace: "only if" 380 | }, { 381 | value: "not unlike", 382 | replace: "similar, alike" 383 | }, { 384 | value: "notwithstanding", 385 | replace: "in spite of, still" 386 | }, { 387 | value: "null and void", 388 | replace: "use either null or void" 389 | }, { 390 | value: "numerous", 391 | replace: "many" 392 | }, { 393 | value: "objective", 394 | replace: "aim, goal" 395 | }, { 396 | value: "obligate", 397 | replace: "bind, compel" 398 | }, { 399 | value: "obtain", 400 | replace: "get" 401 | }, { 402 | value: "on the contrary", 403 | replace: "but, so" 404 | }, { 405 | value: "on the other hand", 406 | replace: "omit; but, so" 407 | }, { 408 | value: "one particular", 409 | replace: "one" 410 | }, { 411 | value: "optimum", 412 | replace: "best, greatest, most" 413 | }, { 414 | value: "overall", 415 | replace: "omit" 416 | }, { 417 | value: "owing to the fact that", 418 | replace: "because, since" 419 | }, { 420 | value: "participate", 421 | replace: "take part" 422 | }, { 423 | value: "particulars", 424 | replace: "details" 425 | }, { 426 | value: "pass away", 427 | replace: "die" 428 | }, { 429 | value: "pertaining to", 430 | replace: "about, of, on" 431 | }, { 432 | value: "point in time", 433 | replace: "time, point, moment, now" 434 | }, { 435 | value: "portion", 436 | replace: "part" 437 | }, { 438 | value: "possess", 439 | replace: "have, own" 440 | }, { 441 | value: "preclude", 442 | replace: "prevent" 443 | }, { 444 | value: "previously", 445 | replace: "before" 446 | }, { 447 | value: "prior to", 448 | replace: "before" 449 | }, { 450 | value: "prioritize", 451 | replace: "rank, focus on" 452 | }, { 453 | value: "procure", 454 | replace: "buy, get" 455 | }, { 456 | value: "proficiency", 457 | replace: "skill" 458 | }, { 459 | value: "provided that", 460 | replace: "if" 461 | }, { 462 | value: "purchase", 463 | replace: "buy, sale" 464 | }, { 465 | value: "put simply", 466 | replace: "omit" 467 | }, { 468 | value: "readily apparent", 469 | replace: "clear" 470 | }, { 471 | value: "refer back", 472 | replace: "refer" 473 | }, { 474 | value: "regarding", 475 | replace: "about, of, on" 476 | }, { 477 | value: "relocate", 478 | replace: "move" 479 | }, { 480 | value: "remainder", 481 | replace: "rest" 482 | }, { 483 | value: "remuneration", 484 | replace: "payment" 485 | }, { 486 | value: "require", 487 | replace: "must, need" 488 | }, { 489 | value: "requirement", 490 | replace: "need, rule" 491 | }, { 492 | value: "reside", 493 | replace: "live" 494 | }, { 495 | value: "residence", 496 | replace: "house" 497 | }, { 498 | value: "retain", 499 | replace: "keep" 500 | }, { 501 | value: "satisfy", 502 | replace: "meet, please" 503 | }, { 504 | value: "shall", 505 | replace: "must, will" 506 | }, { 507 | value: "should you wish", 508 | replace: "if you want" 509 | }, { 510 | value: "similar to", 511 | replace: "like" 512 | }, { 513 | value: "solicit", 514 | replace: "ask for, request" 515 | }, { 516 | value: "span across", 517 | replace: "span, cross" 518 | }, { 519 | value: "strategize", 520 | replace: "plan" 521 | }, { 522 | value: "subsequent", 523 | replace: "later, next, after, then" 524 | }, { 525 | value: "substantial", 526 | replace: "large, much" 527 | }, { 528 | value: "successfully complete", 529 | replace: "complete, pass" 530 | }, { 531 | value: "sufficient", 532 | replace: "enough" 533 | }, { 534 | value: "terminate", 535 | replace: "end, stop" 536 | }, { 537 | value: "the month of", 538 | replace: "omit" 539 | }, { 540 | value: "therefore", 541 | replace: "thus, so" 542 | }, { 543 | value: "time period", 544 | replace: "time, period" 545 | }, { 546 | value: "took advantage of", 547 | replace: "preyed on" 548 | }, { 549 | value: "transmit", 550 | replace: "send" 551 | }, { 552 | value: "transpire", 553 | replace: "happen" 554 | }, { 555 | value: "until such time as", 556 | replace: "until" 557 | }, { 558 | value: "utilization", 559 | replace: "use" 560 | }, { 561 | value: "utilize", 562 | replace: "use" 563 | }, { 564 | value: "validate", 565 | replace: "confirm" 566 | }, { 567 | value: "various different", 568 | replace: "various, different" 569 | }, { 570 | value: "very", 571 | replace: "omit" 572 | }, { 573 | value: "whether or not", 574 | replace: "whether" 575 | }, { 576 | value: "with respect to", 577 | replace: "on, about" 578 | }, { 579 | value: "with the exception of", 580 | replace: "except for" 581 | }, { 582 | value: "witnessed", 583 | replace: "saw, seen" 584 | } 585 | ]; 586 | -------------------------------------------------------------------------------- /lib/en/data/weasel.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | exceptions: [ 3 | 'many', 4 | 'few' 5 | ], 6 | list: [ 7 | 'are a number', 8 | 'clearly', 9 | 'completely', 10 | 'exceedingly', 11 | 'excellent', 12 | 'extremely', 13 | 'fairly', 14 | 'few', 15 | 'huge', 16 | 'interestingly', 17 | 'is a number', 18 | 'largely', 19 | 'many', 20 | 'mostly', 21 | 'obviously', 22 | 'quite', 23 | 'relatively', 24 | 'remarkably', 25 | 'several', 26 | 'significantly', 27 | 'substantially', 28 | 'surprisingly', 29 | 'tiny', 30 | 'various', 31 | 'vast', 32 | 'very' 33 | ] 34 | }; 35 | -------------------------------------------------------------------------------- /lib/en/index.js: -------------------------------------------------------------------------------- 1 | 2 | module.exports = { 3 | 'so': require('./so'), 4 | 'weasel': require('./weasel'), 5 | 'lexical-illusion': require('./lexical-illusion'), 6 | 'passive': require('./passive'), 7 | 'simplicity': require('./simplicity'), 8 | 'adverbs': require('./adverbs'), 9 | 'readibility': require('./readibility'), 10 | 'sentence:start': require('./sentence-start'), 11 | 'sentence:end': require('./sentence-end'), 12 | 'sentence:uppercase': require('./sentence-uppercase') 13 | }; 14 | -------------------------------------------------------------------------------- /lib/en/lexical-illusion.js: -------------------------------------------------------------------------------- 1 | // http://matt.might.net/articles/shell-scripts-for-passive-voice-weasel-words-duplicates/ 2 | 3 | // Example: 4 | // Many readers are not aware that the 5 | // the brain will automatically ignore 6 | // a second instance of the word "the" 7 | // when it starts a new line. 8 | 9 | var _ = require("lodash"); 10 | var levels = require("../levels"); 11 | var tokenize = require("../tokenize"); 12 | 13 | module.exports = tokenize.check( 14 | // Tokenize as sections 15 | tokenize.sections(), 16 | 17 | // For each sentence 18 | tokenize.flow( 19 | // Tokenize as words 20 | tokenize.words(), 21 | 22 | // For each sentences 23 | tokenize.filter(function(word, token, prev) { 24 | return (prev && token.value.toLowerCase() === prev.value.toLowerCase()); 25 | }) 26 | ), 27 | 28 | // Output 29 | tokenize.define({ 30 | message: '"<%= value %>" is repeated' 31 | }) 32 | ); 33 | module.exports.level = levels.CRITICAL; 34 | -------------------------------------------------------------------------------- /lib/en/passive.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | var tokenize = require("../tokenize"); 3 | var levels = require("../levels"); 4 | var passive = require("./data/passive"); 5 | 6 | var re = new RegExp('\\b(am|are|were|being|is|been|was|be)\\b\\s*([\\w]+ed|' + _.pluck(passive.list, "value").join('|') + ')\\b', 'gi'); 7 | 8 | module.exports = tokenize.check( 9 | tokenize.re(re), 10 | tokenize.define(function (text, token, prev) { 11 | var replacement = _.find(passive.list, { value: token.match[2] }); 12 | if (replacement) replacement = [{ value: replacement.replace }]; 13 | 14 | return { 15 | message: '"<%= value %>" may be passive voice', 16 | replacements: replacement 17 | }; 18 | }) 19 | ); 20 | module.exports.level = levels.WARNING; 21 | -------------------------------------------------------------------------------- /lib/en/readibility.js: -------------------------------------------------------------------------------- 1 | // Automated Readability Index 2 | // http://en.wikipedia.org/wiki/Automated_Readability_Index 3 | 4 | var tokenize = require("../tokenize"); 5 | var levels = require("../levels"); 6 | var english = require("tokenize-english")(tokenize); 7 | 8 | module.exports = tokenize.check( 9 | // Tokenize as sentences 10 | english.sentences(), 11 | 12 | // Output 13 | tokenize.define(function(sentence) { 14 | var level; 15 | var size = sentence.length; 16 | var words = tokenize.words()(sentence).length; 17 | var characters = tokenize.characters()(sentence).length; 18 | var sentences = 1; 19 | var score = 4.75*(characters/words) + 0.5 * (words/sentences) - 21.43; 20 | 21 | if (words > 14) { 22 | if (score > 12 && score <= 16) { 23 | level = levels.SUGGESTION; 24 | } else if (score > 16) { 25 | level = levels.WARNING; 26 | } 27 | } 28 | 29 | if (!level) return null; 30 | return { 31 | level: level, 32 | message: "sentence is "+(level == levels.WARNING? "very " : "")+"hard to read" 33 | }; 34 | }) 35 | ); 36 | module.exports.level = levels.WARNING; 37 | -------------------------------------------------------------------------------- /lib/en/sentence-end.js: -------------------------------------------------------------------------------- 1 | // There should be no space between a sentence and its ending punctuation 2 | // http://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation-mark 3 | 4 | var tokenize = require("../tokenize"); 5 | var levels = require("../levels"); 6 | var english = require("tokenize-english")(tokenize); 7 | 8 | module.exports = tokenize.check( 9 | // Tokenize as sentences 10 | english.sentences(), 11 | 12 | // Output 13 | tokenize.define(function(sentence, current, prev) { 14 | if (sentence[sentence.length - 1] != '.' || sentence[sentence.length - 2] != ' ') return null; 15 | 16 | return { 17 | index: sentence.length - 2, 18 | offset: 1, 19 | message: "there should be no space between a sentence and its ending punctuation" 20 | }; 21 | }) 22 | ); 23 | module.exports.level = levels.ERROR; 24 | -------------------------------------------------------------------------------- /lib/en/sentence-start.js: -------------------------------------------------------------------------------- 1 | // Sentences should be preceded by a space 2 | 3 | var tokenize = require("../tokenize"); 4 | var levels = require("../levels"); 5 | var english = require("tokenize-english")(tokenize); 6 | 7 | module.exports = tokenize.check( 8 | // Tokenize as sentences 9 | english.sentences(), 10 | 11 | // Output 12 | tokenize.define(function(sentence, current, prev) { 13 | if (!prev || (prev.index + prev.offset) < current.index || sentence[0] == ' ') return null; 14 | 15 | return { 16 | index: 0, 17 | offset: 1, 18 | message: "sentence should be preceded by a space" 19 | }; 20 | }) 21 | ); 22 | module.exports.level = levels.ERROR; 23 | -------------------------------------------------------------------------------- /lib/en/sentence-uppercase.js: -------------------------------------------------------------------------------- 1 | // Sentences should start with a uppercase letter 2 | 3 | var _ = require("lodash"); 4 | var tokenize = require("../tokenize"); 5 | var levels = require("../levels"); 6 | var english = require("tokenize-english")(tokenize); 7 | 8 | var TRIM_RE = /^\s+/; 9 | 10 | module.exports = tokenize.check( 11 | // Tokenize as sentences 12 | english.sentences(), 13 | 14 | // Output 15 | tokenize.define(function(sentence, current, prev) { 16 | var words = tokenize.words()(sentence); 17 | 18 | // Is the letter uppercase? 19 | if (words.length == 0 || words[0].value[0] == words[0].value[0].toUpperCase()) return null; 20 | 21 | return { 22 | index: words[0].index, 23 | offset: words[0].offset, 24 | message: "sentence should start with an uppercase letter", 25 | replacements: [ 26 | { 27 | value: _.capitalize(words[0].value) 28 | } 29 | ] 30 | }; 31 | }) 32 | ); 33 | module.exports.level = levels.ERROR; 34 | -------------------------------------------------------------------------------- /lib/en/simplicity.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | var tokenize = require("../tokenize"); 3 | var levels = require("../levels"); 4 | var simpler = require("./data/simpler"); 5 | 6 | var re = new RegExp('\\b(' + _.pluck(simpler, "value").join('|') + ')\\b', 'gi'); 7 | 8 | module.exports = tokenize.check( 9 | tokenize.re(re), 10 | tokenize.define(function (text, token, prev) { 11 | var replacement = _.find(simpler, { value: text.toLowerCase() }); 12 | if (replacement && replacement.replace) replacement = [{ value: replacement.replace }]; 13 | 14 | return { 15 | message: '"<%= value %>" has a simpler alternative', 16 | replacements: replacement 17 | }; 18 | }) 19 | ); 20 | module.exports.level = levels.SUGGESTION; 21 | -------------------------------------------------------------------------------- /lib/en/so.js: -------------------------------------------------------------------------------- 1 | // http://www.nytimes.com/2010/05/22/us/22iht-currents.html?_r=0 2 | // http://comminfo.rutgers.edu/images/comprofiler/plug_profilegallery/84/pg_2103855866.pdf 3 | 4 | var tokenize = require("../tokenize"); 5 | var levels = require("../levels"); 6 | var english = require("tokenize-english")(tokenize); 7 | 8 | module.exports = tokenize.check( 9 | // Tokenize as sentences 10 | english.sentences(), 11 | 12 | // Match the ones starting with "so" 13 | tokenize.re(/^(\s)*so\b[\s\S]/i), 14 | 15 | // Output 16 | tokenize.define({ 17 | message: "omit 'So' from the beginning of sentences" 18 | }) 19 | ); 20 | module.exports.level = levels.SUGGESTION; 21 | -------------------------------------------------------------------------------- /lib/en/weasel.js: -------------------------------------------------------------------------------- 1 | // http://en.wikipedia.org/wiki/Weasel_word 2 | 3 | var _ = require("lodash") 4 | var tokenize = require("../tokenize"); 5 | var levels = require("../levels"); 6 | var weaselWords = require("./data/weasel"); 7 | 8 | module.exports = tokenize.check( 9 | tokenize.words(), 10 | 11 | // Filter some exceptions 12 | tokenize.filter(function(word, token, prev) { 13 | return ( 14 | !(prev && prev.value.toLowerCase() == "too" && _.contains(weaselWords.exceptions, word)) 15 | && _.contains(weaselWords.list, word.toLowerCase()) 16 | ); 17 | }), 18 | 19 | // Output warning 20 | tokenize.define({ 21 | message: '"<%= value %>" is a weasel word' 22 | }) 23 | ); 24 | module.exports.level = levels.WARNING; 25 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | 3 | var languages = require("./languages"); 4 | var levels = require("./levels"); 5 | var cache = require("./cache"); 6 | var tokenize = require("./tokenize"); 7 | 8 | function rousseau(text, options, callback) { 9 | var checks, processCheck; 10 | 11 | if (_.isFunction(options)) { 12 | callback = options; 13 | options = {}; 14 | } 15 | 16 | 17 | options = _.defaults(options || {}, { 18 | // Language to use 19 | language: "en", 20 | 21 | // Minimum level 22 | level: levels.SUGGESTION, 23 | 24 | // Cache limit 25 | cache: 10000, 26 | 27 | // Only checks to apply 28 | only: [], 29 | 30 | // Checks to disable/configure 31 | checks: {} 32 | }); 33 | 34 | // Build list of checks from language 35 | checks = _.chain([ 36 | options.language, 37 | _.first(options.language.split("_")) 38 | ]) 39 | .uniq() 40 | .reduce(function(_checks, lng) { 41 | return _checks || languages[lng]; 42 | }, null) 43 | .omit(function(check, name) { 44 | // Check if only this one 45 | if (options.only.length > 0 && !_.contains(options.only, name)) return true; 46 | 47 | // Check if enabled 48 | if (options.checks[name] === false) return true 49 | 50 | // Check if level is supperior to the filtered one 51 | if (check.level && levels.order(check.level) < levels.order(options.level)) return true; 52 | 53 | return false; 54 | }) 55 | .pairs() 56 | .value(); 57 | 58 | // Extends with custom checks 59 | _.each(options.checks, function(check, checkName) { 60 | if (!_.isFunction(check)) return; 61 | checks.push([checkName, check]); 62 | }); 63 | 64 | // Init cache 65 | cache.setLimit(options.cache); 66 | 67 | // Apply checks 68 | var results = []; 69 | 70 | processCheck = function() { 71 | var checkType; 72 | var check = checks.shift(); 73 | 74 | if (!check) { 75 | // Sort suggestions by position and level 76 | results = results.sort(function(t1, t2) { 77 | if (t1.index < t2.index) { 78 | return -1; 79 | } else if (t1.index > t2.index) { 80 | return 1; 81 | } else { 82 | return (levels.order(t1.level) < levels.order(t2.level)) ?-1 : 1; 83 | } 84 | }); 85 | 86 | callback(undefined, results); 87 | } else { 88 | checkType = check[0]; 89 | check = check[1]; 90 | 91 | check(text, options.checks[checkType] || {}, function(err, _results) { 92 | if (err) return callback(err); 93 | 94 | _results = _.chain(_results) 95 | .map(function(tok) { 96 | tok.type = tok.type || checkType; 97 | tok.level = tok.level || check.level || levels.SUGGESTION; 98 | 99 | // Filter tokens 100 | if (levels.order(tok.level) < levels.order(options.level)) return null; 101 | 102 | return tok; 103 | }) 104 | .compact() 105 | .value(); 106 | 107 | results = results.concat(_results); 108 | 109 | // Pass to next check 110 | processCheck(); 111 | }); 112 | } 113 | } 114 | 115 | processCheck(); 116 | } 117 | 118 | 119 | module.exports = rousseau; 120 | module.exports.languages = _.keys(languages); 121 | module.exports.levels = levels; 122 | module.exports.tokenize = tokenize; 123 | module.exports.cache = cache; 124 | 125 | -------------------------------------------------------------------------------- /lib/languages.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | en: require("./en") 3 | }; 4 | -------------------------------------------------------------------------------- /lib/levels.js: -------------------------------------------------------------------------------- 1 | var LEVELS = { 2 | SUGGESTION: "suggestion", 3 | WARNING: "warning", 4 | ERROR: "error", 5 | CRITICAL: "critical" 6 | }; 7 | 8 | var ORDER = [ 9 | LEVELS.SUGGESTION, 10 | LEVELS.WARNING, 11 | LEVELS.ERROR, 12 | LEVELS.CRITICAL 13 | ]; 14 | 15 | function levelOrder(lvl) { 16 | return ORDER.indexOf(lvl); 17 | } 18 | 19 | module.exports = LEVELS; 20 | module.exports.order = levelOrder; -------------------------------------------------------------------------------- /lib/tokenize.js: -------------------------------------------------------------------------------- 1 | var _ = require('lodash'); 2 | var Tokenizer = require('tokenize-text'); 3 | 4 | var cache = require('./cache').namespace('tokenizer'); 5 | 6 | // Create tokenizer with cache config 7 | var tokenize = new Tokenizer({ 8 | cacheGet: cache.get, 9 | cacheSet: cache.set 10 | }); 11 | 12 | // Convert a list of tokens to some suggestions 13 | function tokenizeDefine(infos) { 14 | return tokenize.split(function(text, tok) { 15 | var _infos = _.isFunction(infos)? infos.apply(null, arguments) : _.clone(infos); 16 | if (!_infos) return null; 17 | 18 | // Defaults for the sugegstion 19 | _infos = _.defaults(_infos, { 20 | index: 0, 21 | message: "", 22 | replacements: [] 23 | }); 24 | 25 | _infos = _.extend(tok, _infos); 26 | 27 | _infos.message = _.template(_infos.message)(_infos); 28 | 29 | return _infos; 30 | }); 31 | } 32 | 33 | // Apply a test on tokens 34 | function tokenizeCheck() { 35 | var fn = tokenize.serie.apply(tokenize, arguments); 36 | 37 | return function(text, opts, callback) { 38 | try { 39 | callback(null, fn(text, opts)); 40 | } catch(err) { 41 | callback(err); 42 | } 43 | }; 44 | } 45 | 46 | 47 | module.exports = tokenize; 48 | module.exports.check = tokenizeCheck; 49 | module.exports.define = tokenizeDefine; 50 | -------------------------------------------------------------------------------- /lib/utils/html.js: -------------------------------------------------------------------------------- 1 | var htmlparser = require('htmlparser2'); 2 | 3 | // Tokenize some html content to return tokens of text 4 | function tokenize(content) { 5 | var tokens = []; 6 | var parser = new htmlparser.Parser({ 7 | onopentag: function(name, attribs) { }, 8 | ontext: function(text) { 9 | var start = parser.startIndex; 10 | 11 | tokens.push({ 12 | value: text, 13 | index: start, 14 | offset: text.length 15 | }); 16 | }, 17 | onclosetag: function(tagname) { } 18 | }); 19 | parser.write(content); 20 | parser.end(); 21 | 22 | return tokens; 23 | } 24 | 25 | module.exports = { 26 | tokenize: tokenize 27 | }; 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rousseau", 3 | "version": "1.0.5", 4 | "homepage": "https://github.com/GitbookIO/rousseau", 5 | "description": "Lightweight proofreader", 6 | "main": "lib/index.js", 7 | "dependencies": { 8 | "lodash": "^3.2.0", 9 | "bash-color": "0.0.3", 10 | "cli-table": "0.3.1", 11 | "crc": "3.2.1", 12 | "simple-lru-cache": "0.0.1", 13 | "tokenize-text": "1.1.3", 14 | "tokenize-english": "1.0.3", 15 | "tokenize-htmltext": "1.0.0", 16 | "find-line-column": "0.5.2" 17 | }, 18 | "devDependencies": { 19 | "mocha": "2.3.3", 20 | "should": "7.1.0" 21 | }, 22 | "scripts": { 23 | "test": "mocha --reporter spec --recursive --bail" 24 | }, 25 | "bin": { 26 | "rousseau": "./bin/rousseau.js" 27 | }, 28 | "repository": { 29 | "type": "git", 30 | "url": "https://github.com/GitbookIO/rousseau.git" 31 | }, 32 | "keywords": [ 33 | "proofreading", "language", "native", "spellcheck" 34 | ], 35 | "author": "GitBook ", 36 | "license": "Apache-2.0", 37 | "bugs": { 38 | "url": "https://github.com/GitbookIO/rousseau/issues" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/GitbookIO/rousseau/e7fb314d53074f65449d8e5c02a0dd7c932b83ae/preview.jpg -------------------------------------------------------------------------------- /test/api.js: -------------------------------------------------------------------------------- 1 | var should = require("should"); 2 | var rousseau = require("../lib"); 3 | 4 | describe("API", function() { 5 | it("should provides list of languages", function() { 6 | rousseau.should.have.property("languages"); 7 | rousseau.languages.length.should.be.above(0); 8 | }); 9 | }); 10 | 11 | -------------------------------------------------------------------------------- /test/en.js: -------------------------------------------------------------------------------- 1 | var _ = require("lodash"); 2 | var should = require("should"); 3 | 4 | var rousseau = require("../lib"); 5 | var testRousseau = require('./helper').testRousseau; 6 | 7 | describe("English", function() { 8 | describe("Adverbs", function() { 9 | it("should detect", function(done) { 10 | testRousseau("Allegedly, this sentence is terrible.", { 11 | only: ["adverbs"] 12 | }, done, function(results) { 13 | results.should.have.length(1); 14 | results[0].type.should.be.exactly("adverbs"); 15 | }); 16 | }); 17 | }); 18 | 19 | describe("Lexical Illusions", function() { 20 | it("should detect", function(done) { 21 | testRousseau("the the", { 22 | only: ["lexical-illusion"] 23 | }, done, function(results) { 24 | results.should.have.length(1); 25 | results[0].type.should.be.exactly("lexical-illusion"); 26 | results[0].index.should.be.exactly(4); 27 | }); 28 | }); 29 | 30 | it("should split correctly sentences", function(done) { 31 | testRousseau("offer to sell, sell", { 32 | only: ["lexical-illusion"] 33 | }, done, function(results) { 34 | results.should.have.length(0); 35 | }); 36 | }); 37 | }); 38 | 39 | describe("Passive", function() { 40 | describe("-ed", function(done) { 41 | it("should detect", function(done) { 42 | testRousseau("He was judged.", { 43 | only: ["passive"] 44 | }, done, function(results) { 45 | results.should.have.length(1); 46 | results[0].type.should.be.exactly("passive"); 47 | results[0].index.should.be.exactly(3); 48 | results[0].offset.should.be.exactly(10); 49 | }); 50 | }); 51 | }); 52 | 53 | describe("predefined", function() { 54 | it("should detect and suggest replacements", function(done) { 55 | testRousseau("He was bitten.", { 56 | only: ["passive"] 57 | }, done, function(results) { 58 | results.should.have.length(1); 59 | results[0].type.should.be.exactly("passive"); 60 | results[0].replacements.length.should.be.exactly(1); 61 | }); 62 | }); 63 | }); 64 | }); 65 | 66 | describe("Readibility", function() { 67 | var TEXT = 68 | // Hard to read 69 | "Rousseau highlights long, complex sentences and common errors;" 70 | + " if you see a warning highlight, shorten the sentence or split it." 71 | 72 | // Very hard to read 73 | + "If you see an error highlight, your sentence is so dense and complicated that your readers" 74 | + " will get lost trying to follow its meandering, splitting logic —" 75 | + " try editing this sentence to remove the error."; 76 | 77 | it("should detect", function(done) { 78 | testRousseau(TEXT, { 79 | only: ["readibility"] 80 | }, done, function(results) { 81 | results.should.have.length(2); 82 | 83 | results[0].type.should.be.exactly("readibility"); 84 | results[0].level.should.be.exactly("suggestion"); 85 | 86 | results[1].type.should.be.exactly("readibility"); 87 | results[1].level.should.be.exactly("warning"); 88 | }); 89 | }); 90 | 91 | it("should detect for splitted sentences", function(done) { 92 | var tokens = [ 93 | { 94 | value: "When an x86-based computer is turned on, it begins a complex path to get to the stage where control is transferred to our kernel's \"main\" routine (", 95 | index: 62, 96 | offset: 147 97 | }, 98 | { 99 | value: "). For this course, we are only going to consider the BIOS boot method and not it's successor (UEFI).", 100 | index: 218, 101 | offset: 101 102 | } 103 | ]; 104 | 105 | testRousseau(tokens, { 106 | only: ["readibility"] 107 | }, done, function(results) { 108 | results[0].type.should.be.exactly("readibility"); 109 | results[0].index.should.equal(62); 110 | results[0].offset.should.equal(158); 111 | }); 112 | }) 113 | }); 114 | 115 | describe("Sentences", function() { 116 | describe('Start', function() { 117 | it("should detect sentences not starting with a space", function(done) { 118 | testRousseau("Hello Barney.The bird in the word./nThis is after a new line.", { 119 | only: ["sentence:start"] 120 | }, done, function(results) { 121 | results.should.have.length(1); 122 | results[0].index.should.be.exactly(13); 123 | results[0].offset.should.be.exactly(1); 124 | results[0].type.should.be.exactly("sentence:start"); 125 | }); 126 | }); 127 | }); 128 | 129 | describe('End', function() { 130 | it("should detect sentences not ending with a space before punctuation", function(done) { 131 | testRousseau("Hello Barney. The bird in the word .", { 132 | only: ["sentence:end"] 133 | }, done, function(results) { 134 | results.should.have.length(1); 135 | results[0].index.should.be.exactly(34); 136 | results[0].offset.should.be.exactly(1); 137 | results[0].type.should.be.exactly("sentence:end"); 138 | }); 139 | }); 140 | 141 | it("should not signal this error if punctation is not a dot", function(done) { 142 | testRousseau("The bird in the word !", { 143 | only: ["sentence:end"] 144 | }, done, function(results) { 145 | results.should.have.length(0); 146 | }); 147 | }); 148 | }); 149 | 150 | describe('Uppercase', function() { 151 | it("should detect sentences not starting with a uppercase", function(done) { 152 | testRousseau("hello Barney. The bird in the word !", { 153 | only: ["sentence:uppercase"] 154 | }, done, function(results) { 155 | results.should.have.length(1); 156 | results[0].index.should.be.exactly(0); 157 | results[0].offset.should.be.exactly(5); 158 | results[0].type.should.be.exactly("sentence:uppercase"); 159 | results[0].replacements.length.should.be.exactly(1); 160 | results[0].replacements[0].value.should.be.exactly('Hello'); 161 | }); 162 | }); 163 | 164 | it("should detect sentences not starting with a uppercase (startign with spaces)", function(done) { 165 | testRousseau("Hello Barney! the bird in the word !", { 166 | only: ["sentence:uppercase"] 167 | }, done, function(results) { 168 | results.should.have.length(1); 169 | results[0].index.should.be.exactly(14); 170 | results[0].offset.should.be.exactly(3); 171 | results[0].type.should.be.exactly("sentence:uppercase"); 172 | results[0].replacements.length.should.be.exactly(1); 173 | results[0].replacements[0].value.should.be.exactly('The'); 174 | }); 175 | }); 176 | }); 177 | }); 178 | 179 | describe("Simplicity", function() { 180 | it("should detect and suggest replacement", function(done) { 181 | testRousseau("Acquire more stars", { 182 | only: ["simplicity"] 183 | }, done, function(results) { 184 | results.should.have.length(1); 185 | results[0].type.should.be.exactly("simplicity"); 186 | results[0].replacements.length.should.be.exactly(1); 187 | }); 188 | }); 189 | }); 190 | 191 | describe("So", function() { 192 | it("should detect", function(done) { 193 | testRousseau("So the cat was stole.", { 194 | only: ["so"] 195 | }, done, function(results) { 196 | results.should.have.length(1); 197 | results[0].type.should.be.exactly("so"); 198 | }); 199 | }); 200 | }); 201 | 202 | describe("Weasel", function() { 203 | describe("List", function() { 204 | it("should detect", function(done) { 205 | testRousseau("Remarkably few developers write well.", { 206 | only: ["weasel"] 207 | }, done, function(results) { 208 | results.should.have.length(2); 209 | results[0].type.should.be.exactly("weasel"); 210 | results[0].index.should.be.exactly(0); 211 | results[0].offset.should.be.exactly(10); 212 | 213 | results[1].type.should.be.exactly("weasel"); 214 | results[1].index.should.be.exactly(11); 215 | results[1].offset.should.be.exactly(3); 216 | }); 217 | }); 218 | }); 219 | 220 | describe("Exceptions", function() { 221 | it("should not detect 'too many'", function(done) { 222 | testRousseau("I have too many things.", { 223 | only: ["weasel"] 224 | }, done, function(results) { 225 | results.should.have.length(0); 226 | }); 227 | }); 228 | 229 | it("should not detect 'too few'", function(done) { 230 | testRousseau("I have too few things.", { 231 | only: ["weasel"] 232 | }, done, function(results) { 233 | results.should.have.length(0); 234 | }); 235 | }); 236 | }); 237 | }); 238 | }); 239 | 240 | -------------------------------------------------------------------------------- /test/fixtures/test.html: -------------------------------------------------------------------------------- 1 |

Alternative methods

2 | 3 |

4 | Copy holding or copy reading employs two readers per proof. 5 | 6 | The first reads the text aloud literally as it appears, usually at a comparatively fast but uniform rate. 7 | 8 | The second reader follows along and marks any pertinent differences between what is read and what was typeset. 9 | 10 | This method is appropriate for large quantities of boilerplate text where it is assumed that the number of errors will be comparatively small. 11 |

-------------------------------------------------------------------------------- /test/helper.js: -------------------------------------------------------------------------------- 1 | var rousseau = require("../lib"); 2 | 3 | function testRousseau(text, opts, done, fn) { 4 | rousseau(text, opts || {}, function(err, results) { 5 | if (err) return done(err); 6 | try { 7 | fn(results); 8 | done(); 9 | } catch(err) { 10 | done(err); 11 | } 12 | }); 13 | } 14 | 15 | module.exports = { 16 | testRousseau: testRousseau 17 | }; 18 | --------------------------------------------------------------------------------