Skip to content

Question re: adding extra dictionaries #26

Open
@akotranza

Description

node 12.10.x
nspell 2.1.2

I'm not sure if this is a bug or my misinterpretation of the documentation.

Adding extra dictionaries via

new nspell([{aff: mainaff_buff, dic: maindic_buff}, {dic: extradic_buff}]), or
nspell_instance.dictionary(<extradic_buff>), or
nspell_instance.dictionary(['some','new',words'].join('\n'));

appears to cause all inputs to be considered correct by .correct and .suggest

I do see that the nspell_instance object contains all of the words from both maindic and extradic as well as all of the affix information, but it does not seem to be used 😕

However, using .personal to add extra words does work as expected and testing with both maindic and the extra words produces correct .correct and .suggest outputs.

I'm not sure if I am missing something in the documentation or if this is an issue. I am using the dictionary-en package to load the main aff & dic, and the extra dictionaries are plain word lists in utf-8 loaded into a buffer.

Steps to reproduce:

A. baseline, single dictionary

const maindic = require('dictionary-en')
const nspell = new NSpell(maindic)

nspell.correct('ultrasonogram') // => false; OK b/c not in dictionary
nspell.correct('ultrasongram') // => false; OK
nspell.correct('feleing') // => false; 👍 

nspell.suggest('ultrasonogram') // => [ ]; OK
nspell.suggest('ultrasongram') // => [ ]; OK
nspell.suggest('feleing') // => ['feeling', 'fleeing', ...]; 👍 

B. add words via .dictionary (same behavior if it's another buffer passed in to constructor)

const maindic = require('dictionary-en')
const nspell = new NSpell(maindic)
nspell.dictionary(['ultrasonogram','ultrasonosurgery'].join('\n'))

nspell.correct('ultrasonogram') // => true
nspell.correct('ultrasongram') // => true; 👎 
nspell.correct('feleing') // => true; 👎 

nspell.suggest('ultrasonogram') // => []
nspell.suggest('ultrasongram') // => []
nspell.suggest('feleing') // => []

C. add words via .personal

const maindic = require('dictionary-en')
const nspell = new NSpell(maindic)
nspell.dictionary(['ultrasonogram','ultrasonosurgery'].join('\n'))

nspell.correct('ultrasonogram') // => true
nspell.correct('ultrasongram') // => false
nspell.correct('feleing') // => false

nspell.suggest('ultrasonogram') // => []
nspell.suggest('ultrasongram') // => ['ultrasonogram'] 👍 
nspell.suggest('feleing') // => ['feeling', 'fleeing', ...] 👍 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions