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

Initial support for v2 API #6

Merged
merged 10 commits into from
Feb 12, 2015
Merged

Initial support for v2 API #6

merged 10 commits into from
Feb 12, 2015

Conversation

anaisbetts
Copy link
Contributor

node-spellchecker has a number of deficiencies that this PR starts to fix up:

  • Dictionary is hard-coded to en_US on Windows
  • Dictionaries are hard-coded to the vendor directory, which fails on ASAR because Hunspell can't load it out of an ASAR archive
  • These settings are globals, so having >1 language active is impossible (i.e. if you detect the user switched their keyboard layout to Spanish, you couldn't blow away the old Hunspell)

To fix this, this PR introduces a new class:

Spellchecker

  • setDictionary(language, dictionaryPath) - This method must be called before any other method is called, it configures the language (en_US) and the path to the dictionary (optional, default is .)
  • isMisspelled - Identical to v1 isMisspelled method, returns a bool marking whether a word is misspelled
  • getCorrectionsForMisspelling - Identical to v1 getCorrectionsForMisspelling method, returns a list of corrections for a misspelled word.

This PR also maintains compatibility with the v1 API via creating a default Spellchecker when the original methods are called

@anaisbetts anaisbetts changed the title Initial support for vNext API Initial support for v2 API Feb 11, 2015
@zcbenz
Copy link
Contributor

zcbenz commented Feb 12, 2015

This is awesome!

zcbenz added a commit that referenced this pull request Feb 12, 2015
Initial support for v2 API
@zcbenz zcbenz merged commit bc40e40 into atom:master Feb 12, 2015
@anaisbetts anaisbetts deleted the classify branch February 12, 2015 03:51
@despairblue despairblue mentioned this pull request Feb 17, 2015
@cristianfraser
Copy link

I'm sorry, but how do I use the setDictionary() method? Doing c = require('spellchecker'); c.setDictionary returns undefined, I don't know if I'm missing something or not.

nvm, I realized they're in the Spellchecker class.

@anaisbetts
Copy link
Contributor Author

@cristianfraser The methods directly exported are the old methods left in for compatibility, so existing apps still work

@cristianfraser
Copy link

@paulcbetts So, great tool! But I have one question, how does setDictionary(lang, path) works? I'm currently developing on OSX, and it doesn't seem possible to set a path for each language, it just uses the system's ones? Calling getAvailableDictionaries() returns many languages, none loaded by me so I guess it does. Also, it doesn't show en_US which is in the hunspell_dictionaries folders, though I can set it. Checking the code in spellchecker/src, it seems that for Mac and Windows the path argument isn't used?

I apologize if this isn't the right place to ask, but don't know if I should open an issue for this or simply ask here.

PS: This tidbit I found strange:

> y.setDictionary('en_US')
true
> y.setDictionary('en_USs')
true
> y.setDictionary('en_USsasdf')
true
> y.setDictionary('en_U')
true
> y.setDictionary('aen_U')
false

@anaisbetts
Copy link
Contributor Author

Checking the code in spellchecker/src, it seems that for Mac and Windows the path argument isn't used?

This is correct.

PS: This tidbit I found strange:

OS X is weird.

@cristianfraser
Copy link

Ok, thanks.

So just to be sure, going with major languages like en and es should work on Mac and Windows without adding extra files?

@anaisbetts
Copy link
Contributor Author

@cristianfraser Both >= Windows 8 and OS X actually ship with a ton of dictionaries in-box, I was surprised how complete it was. For Win7, you're on your own to ship Hunspell dictionaries (http://cgit.freedesktop.org/libreoffice/dictionaries/tree is where I was getting them)

soundar-m pushed a commit to soundar-m/node-spellchecker that referenced this pull request May 15, 2020
commit 84b6708
Merge: fef5593 1a0243e
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 19:43:16 2019 -0700

    Merge pull request atom#6 from goddessfreya/goddessfreya-patch-1

    Add clang testing

commit 1a0243e
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 19:37:34 2019 -0700

    Update nodejs.yml

commit 18e838f
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 19:35:27 2019 -0700

    Delete package-lock.json

commit d17cf27
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 19:22:57 2019 -0700

    Update nodejs.yml

commit 81c5ae6
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 19:12:42 2019 -0700

    Update nodejs.yml

commit 2db0f18
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:56:33 2019 -0700

    Update nodejs.yml

commit 855c3c1
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:49:38 2019 -0700

    Update nodejs.yml

commit f80be0a
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:38:49 2019 -0700

    Update nodejs.yml

commit 3c52d66
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:35:04 2019 -0700

    Update nodejs.yml

commit 5fe3493
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:34:31 2019 -0700

    Update nodejs.yml

commit 8c41771
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:34:05 2019 -0700

    Update nodejs.yml

commit 5bd03fe
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:33:49 2019 -0700

    Update nodejs.yml

commit aab4c50
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:33:35 2019 -0700

    Update nodejs.yml

commit 0e6f86f
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:30:31 2019 -0700

    Update nodejs.yml

commit fef5593
Merge: 0c83612 e99e477
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:16:48 2019 -0700

    Merge pull request atom#5 from abetomo/fix_deprecated_callback

    Fix deprecated callback

commit 0c83612
Merge: 2c0d135 5cbdece
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:04:18 2019 -0700

    Merge pull request atom#4 from goddessfreya/Add-Github-actions

    Add Github actions

commit 5cbdece
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:01:01 2019 -0700

    Delete appveyor.yml

commit 4ddcbd3
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 18:00:49 2019 -0700

    Delete .travis.yml

commit c6f6c63
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 17:57:45 2019 -0700

    Update nodejs.yml

commit 84bccbd
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 17:55:23 2019 -0700

    Update nodejs.yml

commit f6720ea
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 17:50:59 2019 -0700

    Update nodejs.yml

commit 514a3f9
Author: Freya Gentz <[email protected]>
Date:   Thu Dec 19 17:31:31 2019 -0700

    Add Github actions

commit e99e477
Author: abetomo <[email protected]>
Date:   Thu Jul 5 10:25:35 2018 +0900

    Fix deprecated callback

    The following warning.

    ```
    ../src/worker.cc: In member function ‘virtual void
    CheckSpellingWorker::HandleOKCallback()’:
    ../src/worker.cc:44:25: warning: ‘v8::Local<v8::Value>
    Nan::Callback::Call(int, v8::Local<v8::Value>*) const’ is deprecated
    [-Wdeprecated-declarations]
       callback->Call(2, argv);
    ```

Signed-off-by: Freya Gentz <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants