Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

SpellChecker.isMisspelled always return false on Windows 10 #72

Open
daijie opened this issue May 18, 2017 · 12 comments
Open

SpellChecker.isMisspelled always return false on Windows 10 #72

daijie opened this issue May 18, 2017 · 12 comments

Comments

@daijie
Copy link

daijie commented May 18, 2017

For example, mathched is misspelled for matched.
SpellChecker.isMisspelled works well on Mac OS X but it always return false on Windows 10.

var SpellChecker = require('spellchecker');
console.log(SpellChecker.isMisspelled('mathched'));

image

@daijie daijie changed the title isMisspelled always Return false on Windows 10 SpellChecker.isMisspelled always Return false on Windows 10 May 18, 2017
@daijie daijie changed the title SpellChecker.isMisspelled always Return false on Windows 10 SpellChecker.isMisspelled always return false on Windows 10 May 18, 2017
@liliakai
Copy link

Seeing this on linux as well.

@daijie
Copy link
Author

daijie commented May 19, 2017

Another example is testt, it's misspelled of test.
Always return false except on Mac.


I have changed to a package called hunspell-spellchecker, slower but works.

@new-player
Copy link

new-player commented Jun 10, 2017

I got it working on linux.
Try setting the LANG environment variable.
export LANG='en_US'
Once it is done, you can run your <file_name>.js file and check.
For more info check this out: https://github.com/atom/node-spellchecker/blob/master/lib/spellchecker.js#L13
Same you can try for windows and check if it works.

Thanks,

@AshDevFr
Copy link

I have the same issue when using it on Windows 7. Adding the LANG variable does not change anything.

@MTRNord
Copy link

MTRNord commented Aug 25, 2017

Any progress on this? :(

@LucasPilarski
Copy link

I know it is late, but I forced it to work.
I did two things - to my webpack build.js file I added process.env.LANG = 'en-UK' variable, and In my app I imported spellchecker and added spellchecker.setDictionary('en-UK'). I do not know which one of these things did the job, but my production build is working as intended.
And to do all of that I needed only a few hours of trial and error and a quick look at the source files.

@derekpankaew
Copy link

derekpankaew commented Nov 20, 2018

Hey Guys,

I was having the same issues in Linux. I fixed it by adding this:

SpellChecker.setDictionary('en-US',SpellChecker.getDictionaryPath())

Where SpellChecker is spellchecker imported.

Basically it sets the dictionary, then uses a function to get the path of the hunspell dictionary.

On Mac it was working without this line of code, for some reason the code didn't work on Linux until I manually set the language & dictionary.

@dmoonfire
Copy link
Contributor

On Windows 10 and Mac, this library uses the system libraries to do spell checking. That means you have to look at the system to figure out what the spell-checking isn't working.

Linux doesn't provide that nor does it have standard locations for dictionary files. That means we can't make any assumptions or automatically enable it on Linux without a locale+directory or a specific dictionary file to work with.

The SpellChecker.getDictionaryPath() sadly only works for en-US because we package a copy of that library with the package. All other languages aren't provided.

@derekpankaew
Copy link

On Windows 10 and Mac, this library uses the system libraries to do spell checking. That means you have to look at the system to figure out what the spell-checking isn't working.

Linux doesn't provide that nor does it have standard locations for dictionary files. That means we can't make any assumptions or automatically enable it on Linux without a locale+directory or a specific dictionary file to work with.

The SpellChecker.getDictionaryPath() sadly only works for en-US because we package a copy of that library with the package. All other languages aren't provided.

Aha - that makes sense now.

Quick question: do you know why results on Mac and Linux might be different, if the dictionary files are the same? I checked the .aff and .dic files with MD5 hash and they're identical, but on Linux the suggested words are often different than on Mac.

@dmoonfire
Copy link
Contributor

Unless you set an environment variable, the Mac completely ignores the dictionary file and uses the operating system one instead. Doesn't even try to open it.

@derekpankaew
Copy link

Unless you set an environment variable, the Mac completely ignores the dictionary file and uses the operating system one instead. Doesn't even try to open it.

Ohhhhh that's why. I was banging my head against a wall for a couple hours yesterday trying to figure this out. I'll send an environment variable. Thanks!

@niftylettuce
Copy link

You can use https://github.com/Wulf/nodehun in the meanwhile. brew install hunspell or sudo apt-get install hunspell. Not sure about Windows support, but it looks like Chocolatey has hunspell package as well.

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

No branches or pull requests

9 participants