nspell icon indicating copy to clipboard operation
nspell copied to clipboard

nspell.add fails to add word to german dictionary

Open GrayedFox opened this issue 5 years ago • 1 comments
trafficstars

Description

nspell sometimes fails to add words to the German dictionary (taken from wooorm/dictionaries).

The gist of the bug is that nspell fails to add words to the German dictionary if those words are lowercase forms of words that should be capitalised (nouns in German are always capitalised).

The test words used in the repo are "zeit" and "kablam". Adding "kablam" works as expected and the same is true for other words that do not have a correct German form. Adding "zeit" (or "brot") both exhibit the bug, and the thing they have in common is that they are both German nouns that should be capitalised.

Reproduction Steps and Code

This is the test repo with the code required to reproduce the bug.

  1. npm install nspell
  2. npm install dictionary-de - installs the German dictionary from https://github.com/wooorm/dictionaries/tree/main/dictionaries/de
  3. Use the following code after loading the DE dictionary:
const nspell = require('nspell')
const dictionaryDe = require('dictionary-de')

// wrap dictionary functions so we can populate languageCodes in order of dictionaries loaded
// (dictionary callbacks return error or dictionary only)
function onload (err, dictionary) {
  const spell = nspell(dictionary)
  spell.correct('zeit')
  spell.add('zeit')
  if (!spell.correct('zeit')) console.log('\x1b[31m%s\x1b[0m', `"zeit" still incorrect!`)
  spell.remove('zeit')
  spell.add('zeit')
  if (spell.correct('zeit')) console.log('\x1b[32m%s\x1b[0m',`"zeit" is now correct (after removing and then adding it again)`)

  spell.correct('kablam')
  spell.add('kablam')
  if (spell.correct('kablam')) console.log('\x1b[32m%s\x1b[0m',`"kablam" is now correct`)
}

dictionaryDe(onload)

Work Around

The work around is to remove the word from the dictionary if it is still incorrect, which will allow us to add it successfully and have it marked as correct by nspell.

GrayedFox avatar Jul 03 '20 15:07 GrayedFox

@wooorm I have removed the other comment and updated the description to be exact after narrowing this down. What a head spin, I was sure it was something on my end - perhaps the new German dictionary has some funky rules? Enjoy your weekend!

GrayedFox avatar Jul 04 '20 10:07 GrayedFox