jupyterlab-contrib / spellchecker

Spellchecker for JupyterLab notebook markdown cells and file editor.
BSD 3-Clause "New" or "Revised" License
209 stars 20 forks source link

Custom location of dictionaries #111

Open zdposter opened 2 years ago

zdposter commented 2 years ago

Please allow to set custom location of (hunspell) dictionaries - I do not want to have the same dictionaries on multiple location.

krassowski commented 2 years ago

What locations are you using? Maybe we could just add them for everyone if that makes sense. Also, which operating system? On the other hand, have you considered symlinking?

zdposter commented 2 years ago

I use windows. I did not consider symlink - IMO that is workaround. I prefer cleaner solution with config option. Hunspell is used these projects I use regularly: libreoffice, chromium, firefox, thunderbird, notepad++ (maybe more).

Hunspell checks for env variable DICPATH + it looks at many different locations (hunspell.exe -D):

SEARCH PATH:
.;;C:\Hunspell\;C:\Users\USER\Application Data\OpenOffice.org 2\user\wordbook;C:\Users\USER\AppData\Roaming\LibreOffice\4\user\wordbook;C:\Program files\OpenOffice.org 2.4\share\dict\ooo\;C:\Program files\OpenOffice.org 2.3\share\dict\ooo\;C:\Program files\OpenOffice.org 2.2\share\dict\ooo\;C:\Program files\OpenOffice.org 2.1\share\dict\ooo\;C:\Program files\OpenOffice.org 2.0\share\dict\ooo\C:\Program Files\LibreOffice\share\extensions;C:\Program Files (x86)\LibreOffice\share\extensions
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
C:\Users\USER\AppData\Roaming\LibreOffice\4\user\wordbook\standard

https://github.com/hunspell/hunspell/blob/80d24cc3a664d04bbc62be27e1580d1aa181900b/src/tools/hunspell.cxx#L2041-L2060

https://github.com/hunspell/hunspell/blob/80d24cc3a664d04bbc62be27e1580d1aa181900b/src/tools/hunspell.cxx#L118-L147

krassowski commented 2 years ago

I think that it would be nice to add these here:

https://github.com/jupyterlab-contrib/spellchecker/blob/05487e2c588961ff8e1550cc55c5e80516294bed/jupyterlab_spellchecker/dictionaries.py#L21-L23

Though we would likely need to do some variable name expansions to cover USERs and possibly allow glob patterns to allow for different open/libre office versions?

https://github.com/jupyterlab-contrib/spellchecker/blob/05487e2c588961ff8e1550cc55c5e80516294bed/jupyterlab_spellchecker/dictionaries.py#L124

ocordes commented 2 years ago

This looks good so far, the problem is to cover all possible directories for the different OSes. Linux is easy, but for Darwin you have different ways to install the dictionaries, my dictionaries are in ~/Library/Spellchecker ... actually I don't have a clue how this can be addressed in Windows ...