### Install dictionary-en via npm Source: https://github.com/wooorm/nspell/blob/main/readme.md Install the English dictionary package, which is recommended to use with nspell. ```sh npm install dictionary-en ``` -------------------------------- ### Install nspell via npm Source: https://github.com/wooorm/nspell/blob/main/readme.md Install the nspell package using npm. This is the primary installation command. ```sh npm install nspell ``` -------------------------------- ### Dutch affix document example (SET UTF-8, KEY, WORDCHARS, REP, SFX) Source: https://github.com/wooorm/nspell/blob/main/readme.md Example of a paraphrased Dutch affix document defining the language, keyboard, flags, and more. Not every option shown is supported in nspell; see the Affix options list for supported options. ```text SET UTF-8 KEY qwertyuiop|asdfghjkl|zxcvbnm|qawsedrftgyhujikolp|azsxdcfvgbhnjmk|aze|qsd|lm|wx|aqz|qws| WORDCHARS '’0123456789ij.-/ REP 487 REP e en REP ji ij REP u oe # … SFX An Y 11 SFX An 0 de d SFX An 0 fe f SFX An 0 ge g # … ``` -------------------------------- ### Get spelling info with NSpell#spell Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns an object with correct, forbidden, and warn flags for the given word. Example shows output for 'colour' and 'color'. ```javascript spell.spell('colour') // => {correct: false, forbidden: false, warn: false} spell.spell('color') // => {correct: true, forbidden: false, warn: false} ``` -------------------------------- ### Use nspell with dictionary-en to check and suggest spellings Source: https://github.com/wooorm/nspell/blob/main/readme.md Loads the dictionary-en package and creates an nspell instance. Shows how to check spelling with correct(), get suggestions with suggest(), and add custom words with add(). The output comments show expected results: 'colour' is incorrect, 'color' is correct, and 'npm' becomes correct after adding it. ```javascript var dictionary = require('dictionary-en') var nspell = require('nspell') dictionary(ondictionary) function ondictionary(err, dict) { if (err) { throw err } var spell = nspell(dict) console.log(spell.correct('colour')) // => false console.log(spell.suggest('colour')) // => ['color'] console.log(spell.correct('color')) // => true console.log(spell.correct('npm')) // => false spell.add('npm') console.log(spell.correct('npm')) // => true } ``` -------------------------------- ### NSpell#wordCharacters() Source: https://github.com/wooorm/nspell/blob/main/readme.md Gets extra word characters defined by the loaded affix file. Returns a string or null. ```APIDOC ## NSpell#wordCharacters() ### Description Get extra word characters defined by the loaded affix file. Most affix files don’t set these, but for example the en dictionary sets `0123456789`. ### Method Instance method ### Parameters None ### Returns `string?` - Defined word characters, if any. ### Example ```js spell.wordCharacters() // => '0123456789' ``` ``` -------------------------------- ### Add word to dictionary with NSpell#add Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds a word to known words. Without a model, the word is marked correct and appears in suggestions. With a model, the word is handled like the model. Example shows before and after adding 'npm'. ```javascript spell.correct('npm') // => false spell.suggest('nnpm') // => ['ppm', 'bpm', …] spell.add('npm') spell.correct('npm') // => true spell.suggest('nnpm') // => ['npm'] ``` -------------------------------- ### Suggest corrections with NSpell#suggest Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns an array of suggested correctly spelled words close to the given word. Example shows suggestions for 'colour', 'color', 'html', and 'alot'. ```javascript spell.suggest('colour') // => ['color'] spell.suggest('color') // => [] spell.suggest('html') // => ['HTML'] spell.suggest('alot') // => ['allot', 'slot', 'clot', …] ``` -------------------------------- ### Get extra word characters with NSpell#wordCharacters Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns extra word characters defined by the loaded affix file, or null if none. Example shows '0123456789' for the en dictionary. ```javascript spell.wordCharacters() // => '0123456789' ``` -------------------------------- ### Check word spelling with NSpell#correct Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns true if the word is correctly spelled, false otherwise. Example shows correct, incorrect, and misspelled words. ```javascript spell.correct('color') // => true spell.correct('html') // => false spell.correct('abreviation') // => false ``` -------------------------------- ### NSpell#spell(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Gets spelling information for a word, including correctness, forbidden status, and warning status. ```APIDOC ## NSpell#spell(word) ### Description Get spelling information for `word`. ### Method Instance method ### Parameters - **word** (string) - Required - Word to check ### Returns Object with the following properties: - **correct** (boolean) - Whether `word` is correctly spelled - **forbidden** (boolean) - Whether `word` is actually correct, but forbidden from showing up as such (often by the users wish) - **warn** (boolean) - Whether `word` is correct, but should trigger a warning (rarely used in dictionaries) ### Example ```js spell.spell('colour') // => {correct: false, forbidden: false, warn: false} spell.spell('color') // => {correct: true, forbidden: false, warn: false} ``` ``` -------------------------------- ### NSpell#personal(dic) Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds a personal dictionary. Lines starting with '*' mark a word as forbidden, and splitting with '/' models the left side after the right word. ```APIDOC ## NSpell#personal(dic) ### Description Add a personal dictionary. ### Method Instance method ### Parameters - **dic** (Buffer or string) - Required - Dictionary document to use; must be in UTF-8 when buffer ### Returns `NSpell` - Operated on instance. ### Note Lines starting with a `*` mark a word as forbidden, which results in them being seen as incorrect, and prevents them from showing up in suggestions. Splitting a line in two with a slash, adds the left side and models it after the already known right word. ### Example ```js spell.personal(['foo', 'bar/color', '*baz'].join('\n')) ``` ``` -------------------------------- ### Remove word from dictionary with NSpell#remove Source: https://github.com/wooorm/nspell/blob/main/readme.md Removes a word from known words. Example shows before and after removing 'color'. ```javascript spell.correct('color') // => true spell.remove('color') spell.correct('color') // => false ``` -------------------------------- ### Add personal dictionary with NSpell#personal Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds a personal dictionary. Lines starting with '*' mark words as forbidden; splitting a line with '/' adds the left side modeled after the right word. ```javascript spell.personal(['foo', 'bar/color', '*baz'].join('\n')) ``` -------------------------------- ### NSpell(dictionary) Source: https://github.com/wooorm/nspell/blob/main/readme.md Constructor for creating a new nspell instance. ```APIDOC ## NSpell(dictionary) ### Description Creates a new spell-checker instance with the given dictionary. ### Method Constructor ### Parameters #### Parameters - **dictionary** (Object) - Required - The dictionary to use, containing `dic` and `aff` properties. ### Request Example ```js var nspell = require('nspell') var dictionary = require('dictionary-en') var spell = nspell(dictionary) ``` ``` -------------------------------- ### NSpell#suggest(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Suggests correctly spelled words close to the given word. Returns an array of suggestions. ```APIDOC ## NSpell#suggest(word) ### Description Suggests correctly spelled words close to `word`. ### Method Instance method ### Parameters - **word** (string) - Required - Word to suggest spelling corrections for ### Returns `Array.` - List with zero or more suggestions. ### Example ```js spell.suggest('colour') // => ['color'] spell.suggest('color') // => [] spell.suggest('html') // => ['HTML'] spell.suggest('alot') // => ['allot', 'slot', 'clot', …] ``` ``` -------------------------------- ### NSpell#dictionary(dic) Source: https://github.com/wooorm/nspell/blob/main/readme.md Sets the dictionary to use. ```APIDOC ## NSpell#dictionary(dic) ### Description Sets the dictionary to use. ### Method dictionary ### Parameters #### Parameters - **dic** (Object) - Required - The dictionary to use, containing `dic` and `aff` properties. ``` -------------------------------- ### NSpell(dictionary) Source: https://github.com/wooorm/nspell/blob/main/readme.md Creates a new spell checker instance. Requires an affix document, optionally with a dictionary. Accepts an object, affix and dictionary strings, or an array of dictionary objects. ```APIDOC ## NSpell(dictionary) ### Description Creates a new spell checker instance. Requires an affix document, optionally with a dictionary. ### Method Constructor ### Parameters - **dictionary** (Object) - Required - Object with `aff` (required) and `dic` (optional) properties - **aff** (Buffer or string) - Required - Affix document to use. Must be in UTF-8 when buffer - **dic** (Buffer or string) - Optional - Dictionary document to use. Must be in UTF-8 when buffer - **dictionaries** (Array.) - Required - List of `dictionary` objects. The first must have an `aff` key, other `aff` keys are ignored ### Returns New instance of `NSpell`. ``` -------------------------------- ### NSpell#personal(dic) Source: https://github.com/wooorm/nspell/blob/main/readme.md Sets the personal dictionary to use. ```APIDOC ## NSpell#personal(dic) ### Description Sets the personal dictionary to use. ### Method personal ### Parameters #### Parameters - **dic** (Object) - Required - The personal dictionary to use. ``` -------------------------------- ### NSpell#add(word[, model]) Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds a word to the personal dictionary. ```APIDOC ## NSpell#add(word[, model]) ### Description Adds a word to the personal dictionary. ### Method add ### Parameters #### Parameters - **word** (string) - Required - The word to add. - **model** (string) - Optional - The model to use for the word. ``` -------------------------------- ### NSpell#add(word[, model]) Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds a word to known words. If a model is given, the word is handled the same as the model. ```APIDOC ## NSpell#add(word[, model]) ### Description Add `word` to known words. If no model is given, the word will be marked as correct in the future, and will show up in spelling suggestions. If a model is given, `word` will be handled the same as `model`. ### Method Instance method ### Parameters - **word** (string) - Required - Word to add - **model** (string, optional) - Known word to model `word` after ### Returns `NSpell` - Operated on instance. ### Example ```js spell.correct('npm') // => false spell.suggest('nnpm') // => ['ppm', 'bpm', …] spell.add('npm') spell.correct('npm') // => true spell.suggest('nnpm') // => ['npm'] ``` ``` -------------------------------- ### NSpell#suggest(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Suggests correct spellings for a misspelled word. ```APIDOC ## NSpell#suggest(word) ### Description Suggests correct spellings for a misspelled word. ### Method suggest ### Parameters #### Parameters - **word** (string) - Required - The word to get suggestions for. ### Response #### Success Response - **Array** - List of suggested correct spellings. ``` -------------------------------- ### NSpell#spell(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns an object with `correct` and `suggest` properties for the given word. ```APIDOC ## NSpell#spell(word) ### Description Returns an object with `correct` and `suggest` properties for the given word. ### Method spell ### Parameters #### Parameters - **word** (string) - Required - The word to check. ### Response #### Success Response - **Object** - An object with `correct` (boolean) and `suggest` (Array) properties. ``` -------------------------------- ### NSpell#wordCharacters() Source: https://github.com/wooorm/nspell/blob/main/readme.md Returns a list of characters that can be part of a word. ```APIDOC ## NSpell#wordCharacters() ### Description Returns a list of characters that can be part of a word. ### Method wordCharacters ### Response #### Success Response - **Array** - List of word characters. ``` -------------------------------- ### NSpell#correct(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Checks if a word is correctly spelled. ```APIDOC ## NSpell#correct(word) ### Description Checks if a word is correctly spelled according to the dictionary. ### Method correct ### Parameters #### Parameters - **word** (string) - Required - The word to check. ### Response #### Success Response - **boolean** - Whether the word is correctly spelled. ``` -------------------------------- ### NSpell#correct(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Checks if a word is correctly spelled. Returns a boolean indicating correctness. ```APIDOC ## NSpell#correct(word) ### Description Checks if `word` is correctly spelled. ### Method Instance method ### Parameters - **word** (string) - Required - Word to check for correct spelling ### Returns `boolean` - Whether `word` is correctly spelled. ### Example ```js spell.correct('color') // => true spell.correct('html') // => false spell.correct('abreviation') // => false ``` ``` -------------------------------- ### NSpell#dictionary(dic) Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds an extra dictionary to the spellchecker. The dictionary must be designed to work with the already loaded affix. ```APIDOC ## NSpell#dictionary(dic) ### Description Add an extra dictionary to the spellchecker. ### Method Instance method ### Parameters - **dic** (Buffer or string) - Required - Dictionary document to use; must be in UTF-8 when buffer ### Returns `NSpell` - Operated on instance. ### Note The given `dic` must be designed to work with the already loaded affix. It’s not possible to add dictionary files from different languages together (use two `NSpell` instances for that). ### Example ```js spell.dictionary( ['5', 'npm', 'nullish', 'rebase', 'SHA', 'stringification'].join('\n') ) ``` ``` -------------------------------- ### Add extra dictionary with NSpell#dictionary Source: https://github.com/wooorm/nspell/blob/main/readme.md Adds an extra dictionary to the spellchecker. The dictionary must be compatible with the already loaded affix; cannot combine different languages. ```javascript spell.dictionary( ['5', 'npm', 'nullish', 'rebase', 'SHA', 'stringification'].join('\n') ) ``` -------------------------------- ### NSpell#remove(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Removes a word from the personal dictionary. ```APIDOC ## NSpell#remove(word) ### Description Removes a word from the personal dictionary. ### Method remove ### Parameters #### Parameters - **word** (string) - Required - The word to remove. ``` -------------------------------- ### NSpell#remove(word) Source: https://github.com/wooorm/nspell/blob/main/readme.md Removes a word from the known words. ```APIDOC ## NSpell#remove(word) ### Description Remove `word` from the known words. ### Method Instance method ### Parameters - **word** (string) - Required - Word to add ### Returns `NSpell` - Operated on instance. ### Example ```js spell.correct('color') // => true spell.remove('color') spell.correct('color') // => false ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.