redguardtoo / wucuo

Fastest solution to spell check camel case code or plain text
122 stars 4 forks source link

Is it possible to spellcheck a text written in two languages? #6

Closed srustamo closed 4 years ago

srustamo commented 4 years ago

I use enchant, which allows using two dictionaries simultaneously so:

enchant -d ru_RU -l | enchant -d en_US -l

This makes spellchecking of a text written in two languages possible. Any idea if wucuo can do something similar?

I'm setting up a windows environment, and enchant is not available on it.

redguardtoo commented 4 years ago

This is flyspell set up problem. Wucuo is a minor mode to replace the two minor modes provided by package flyspell. But wucuo is still based on package flyspell. So the flyspell set up still works.

Anyway, I updated README and add a sample flyspell set up for multiple dictionaries

srustamo commented 4 years ago

I see. Thanks for the links in the Readme describing the setup.

Do you have any experience setting up the -p key?

  -p dict
 Set path of personal dictionary. Default is $HOME/.hunspell_default. Setting -d or the DICTIONARY environmental variable, personal dictionary will be $HOME/.hunspell_dicname

I'm adding this to my init file, but it fails to write the file into the Dropbox path specified, but writes to $HOME environment var location.

(setq ispell-local-dictionary-alist '(

                    (nil
                     "[[:alpha:]]"
                     "[^[:alpha:]]"
                     "[']"
                     t
                     ("-d" "en_US" "-p" "c:\\Users\\srstan\\Dropbox\\dictionaries\\personal_dict.en")
                     nil
                     iso-8859-1)

                    ("american"
                     "[[:alpha:]]"
                     "[^[:alpha:]]"
                     "[']"
                     t
                     ("-d" "en_US" "-p" "c:\\Users\\srstan\\Dropbox\\dictionaries\\personal_dict.en")
                     nil
                     iso-8859-1)
                    ;; ("russian"
                    ("ru_RU"
                     "[[:alpha:]]"
                     "[^[:alpha:]]"
                     "[']"
                     ;; "[[:alpha:]ÄÖÜéäöüß]"
                     ;; "[^[:alpha:]ÄÖÜéäöüß]"
                     ;; "[']"
                     t
                     ("-d" "ru_RU" "-p" "c:\\Users\\srstan\\Dropbox\\dictionaries\\personal_dict.ru")
                     nil
                     iso-8859-1)
                    ))
redguardtoo commented 4 years ago

I don't know what 's -p,

It's better to set up environment variables.

There a lots of articles about Emacs spell setup, I suggest you follow my way. It's been proved to work on all operating systems and has been tested by many users.

P.lease also double check the hunspell version. Does your hunspell support unix path or windows path?

srustamo commented 4 years ago

How do you handle personal dictionaries, if at all?

redguardtoo commented 4 years ago

I use environment variable $HOME and $DICTPATH.

See https://emacs.stackexchange.com/questions/30008/hunspell-flyspell-and-emacs-on-windows for details.

Personal dictionary is just a plain text file which has different different format from standard hunspell dictionary.

Please read the README, the commands to create your own personal dictionary there.

srustamo commented 4 years ago

Thanks. Very helpful.

My intention was to have a personal dictionary shared across different computers through a Dropbox.

I guess you use $HOME and then could symlink to a Dropbox dir - I'm trying to avoid symlinks. And -p key to hunspell seems to offer a way to put a personal dic to a specified dir, rather than default $HOME.

srustamo commented 4 years ago

P.lease also double check the hunspell version. Does your hunspell support unix path or windows path?

The one I use is a native build from here

redguardtoo commented 4 years ago

Sure. Use -p is a good idea if you don't like environment variable. My job requires me to use Linux, macOS, Windows at the same time. So I avoid hard coding dictionary path.

Run echo Mypersonalword | hunspell -a -d en_US,zh_CN -p /m/path/my-dict.txt to test your hunspell setup

Run hunspell -D to find the search path of dictionaries

srustamo commented 4 years ago

Here's the output of echo with different personal dic files:

personal_dict.ru doesn't have Mypersonalword

PS C:\Users\srstan> echo Mypersonalword | hunspell -a -d en_US,zh_CN -p C:\Users\srstan\Dropbox\dictionaries\personal_dict.ru    
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)                                                             
& Mypersonalword 6 0: Impersonalized, Impersonality, Personalized, Interpersonal, Impersonator, Personalization                  

personal_dict.en has Mypersonalword


PS C:\Users\srstan> echo Mypersonalword | hunspell -a -d en_US,zh_CN -p C:\Users\srstan\Dropbox\dictionaries\personal_dict.en    
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)                                                             
*                                                                                                                                

personal_dict.ru has Mypersonalword

PS C:\Users\srstan> echo Mypersonalword | hunspell -a -d en_US,zh_CN -p C:\Users\srstan\Dropbox\dictionaries\personal_dict.ru    
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)                                                             
*                                                                                                                                

nonexistent no_file

PS C:\Users\srstan> echo Mypersonalword | hunspell -a -d en_US,zh_CN -p C:\Users\srstan\Dropbox\dictionaries\no_file             
@(#) International Ispell Version 3.2.06 (but really Hunspell 1.3.2)                                                             
& Mypersonalword 6 0: Impersonalized, Impersonality, Personalized, Interpersonal, Impersonator, Personalization                  

Looks like -p works in console, but does't work from within Emacs.

hunspell -D produces this:

PS C:\Users\srstan> hunspell -D
SEARCH PATH:
.;;C:\Hunspell\;C:\Users\srstan\Application Data\OpenOffice.org 2\user\wordbook;C:\Hunspell\bin\..\share\hunspell;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\
AVAILABLE DICTIONARIES (path is not mandatory for -d option):
C:\Hunspell\bin\..\share\hunspell\default
C:\Hunspell\bin\..\share\hunspell\en_GB
C:\Hunspell\bin\..\share\hunspell\en_US
C:\Hunspell\bin\..\share\hunspell\ru_RU
LOADED DICTIONARY:
C:\Hunspell\bin\..\share\hunspell\default.aff
C:\Hunspell\bin\..\share\hunspell\default.dic
Hunspell 1.3.2
srustamo commented 4 years ago

When selecting ispell-change-dictionary to Russian, I see these options: image

Only russian works for spelling, ru_RU does not. But I don't have russian in hunspell -D output, only ru_RU. Also strange that there are two ru_RU entries.

I have this in my .init related to ru_RU

    ("ru_RU"
                     "[[:alpha:]]"
                     "[^[:alpha:]]"
                     "[']"
                     t
                     ("-d" "ru_RU" "-p" "c:\\Dropbox\\dictionaries\\personal_dict.ru")
                     nil
                     iso-8859-1)

I'm not sure where russian is coming from. Any idea?

redguardtoo commented 4 years ago

c:\\\\Users\\\\srstan\\\\Dropbox\\\\dictionaries\\\\personal_dict.en or `""c:/Users/srstan/Dropbox/dictionaries/personal_dict.en"

BTW -d option support multiple dictionaries.

srustamo commented 4 years ago

Thanks. Looks like I will need to dive into manpage for hunspell and readup ispell-dictionary-alist docstring. It is huge.