atom / node-spellchecker

SpellChecker Node Module
http://atom.github.io/node-spellchecker
MIT License
300 stars 108 forks source link

SpellChecker.isMisspelled always return false on Windows 10 #72

Open daijie opened 7 years ago

daijie commented 7 years ago

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

liliakai commented 7 years ago

Seeing this on linux as well.

daijie commented 7 years ago

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 commented 7 years ago

I got it working on linux. Try setting the LANG environment variable. export LANG='en_US' Once it is done, you can run your .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 commented 7 years ago

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

MTRNord commented 7 years ago

Any progress on this? :(

LucasPilarski commented 6 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 4 years ago

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.