Support for multiple dictionaries


#1

Normally, vim and its variants download dictionary files which can be invoked later on through spellcheck with set spelllang=en,es spell or spelllang=en,fr spell and so on.

Aspell normally allows to have an--extra-dicts= option in case of multiple dictionaries, or by specifying -l option with the dictionary of your choice.

I can have for example on spell.kak the following modification right after eval

 define-command spell-replace %{ evaluate-commands %sh{
if [ -n "$kak_opt_spell_lang" ]; then                    
    options="-l '$kak_opt_spell_lang'"
fi                                                             
suggestions=$(printf %s "$kak_selection" | eval "aspell -a -l es

which in turn will load the corresponding dictionary after spell is invoked without the need to specify the dictionary, and regardless of whatt the locale LC_MESSAGES is.

But I can’t figure out how to have both dictionaries.


#2

My experience with spell.kak tells me to write something like Emacs’ Flyspell — an asynchronous spellchecking plugin for kakoune, that will constantly check spelling as you type, but I don’t really want to do it because it is tedious and I’m already maintaining somewhat complex plugins.

I wonder if there any language servers for spellchecking out there.


#3

I was only able to get so far. It’s just interesting what the outcome turned out to be. Some words are recognized, while others are not. I think this may have something to do woth the way the encoding is exercised while creating the file from a word list.

I downloaded some of the dictionaries from this github repo

And I created my own word list and named the file myapell.dic

On Aspell Creating an Individual Word List it says to specify the base on the current directory, or else it will create the file on the word list dictionaries at /usr/lib/aspell/.

I had made the mistake of creating the master file without the prefix, and it wasn’t until later when I realized it.

The reason was that I had come across this
post from linuxquestions.org in which the op didn’t specify it. But it’s fine. Since I could always remove it.

Then

 $ aspell --lang=es --encoding=utf-8 create master mydic.rws <
 myaspell.dic

Then back on spell.kak

I added

 -d mydic.rws 

to line 31 and 113 of the file.

But unfortunately, some of the words are not even recognized. e.g., thistle and thistles are fine, third and thirds are not

Edited:

I also read some of the explanation given by the chromium Project about some of the rules that are in use with the .aff files fromHunspell. See
https://www.chromium.org/developers/how-tos/editing-the-spell-checking-dictionaries.

This should apply as well to Aspell .aff files and .dat files from Aspell.

But I also tweaked around with dump master while trying to modify the word list from Aspell itself, especially after reading
https://superuser.com/a/137990 , Aspell seemed to depend largely on the base dictionary itself.

So while creating the file from say both en and es dictionaries, --lang applies to only one. The end result is that it recognizes only one dictionary.

One of the hints by which I have relied, is by having (without modifying any of the dic files) under English the word ‘thirds’ and in Spanish the word ‘perseverarías’ , both properly recognized.

If anyone has a working solution by going this route, please let me know.


#4

Probably related post


#5

I’ve given up on trying to have Aspell working for this use case. Even by having a conf file in place, and by tweaking around with the list option, and the boolean option, it didn’t work.

As far as I can tell, and going by the Aspell Customizing suggestion that appears on the documentation page, there is no possible way to go around this issue.

What I do have in place and which seems to work for now is with Hunspell on the spell.kak file instead.


#6

My experience with spell.kak tells me to write something like Emacs’ Flyspell

The last time I checked Emacs, the function ispell-change-dictionary did absolutely nothing with my issue.

Emacs. Spell check “on fly” for 2 languages

What if anything clears my buffer without further overfilling the init file is jlust beyond me. What does ispell-kill-ispell exactly does, is just another lingering question.

So, fly-spell-mode should be disabled, and it seems fine as soon as meta is invoked again, but then as soon as you enable it whatever changes were made in the form of a curvy underlined notation, goes away too. Lisp must be dead. And by then, one might kiss the kiss principle away as well.
And please, I have zero intention of instigating a flame here.

I don’t know vimscript but I can’t deny either that they didn’t give it some thought to implement mkspell

vim runtime spell

Right now I have hunspell -d es_MX,en_US -a on spell.kak and does exactly what I need

PS: I still find some of the Emacs modes, extremely useful, but if the amount of keystrokes it takes to perform a task are greater, it defeats its utility,