Skip to content

nspell.add fails to add word to german dictionary #25

@GrayedFox

Description

@GrayedFox

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.

Metadata

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