Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GrayedFox opened this issue Jul 3, 2020 · 1 comment
Open

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

GrayedFox opened this issue Jul 3, 2020 · 1 comment

Comments

@GrayedFox
Copy link

GrayedFox commented Jul 3, 2020

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
Copy link
Author

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant