Alternate implementation for spell checker

OK - so the plugin works - I’m pretty happy with the results, there were annoying bugs with the previous versions that are fixed with this rewrite.

I still have a few things to polish, and I would love to get some help from you if you can. There are listed on GitHub with the ‘help-wanted’ label

Really nice job Dmere,
I not having any issues associated with the bellow *spelling* buffer on :write then :kak-spell-list. Kakoune v2020.01.16
It updates the jump list perfectly. Good news :+1:

It’s all rock and roll now :smile: thank Dmere.


Yesterday's workflow

quick update on dependencies:
pip3 install --user kak-spell

clean working copy:
plug-list delete kak-spell install kak-spell

:quit


Step 1:
map global user S ‘: enter-user-mode kak-spell’
map global kak-spell e ‘: kak-spell-enable en_AU :kak-spell ’
map global kak-spell f ‘: kak-spell-enable fr_FR :kak-spell ’

Step 2:
kak CachesExplained.md

Step 3:
,Se
,Sl

Step 4:
newConfig → new Config
:write
,Sl

All worked fine yesterday and today updated to latest kak-spell on master after commit 45208f9

And same-same functionality today, same-file, same-alteration. Maybe because??
set-option global jumpclient client0
Who knows :man_shrugging:


Use stdin to read the buffer #8
Not sure I completely understand the issue here but at a guess:

#!/usr/bin/env python
import sys
# Read stdin into memory
lines = [line.SomeFunction() for line in sys.stdin]

source: dotfiles/bin/strip-indents at main · nvie/dotfiles · GitHub

Well it should not have worked (see issue 9 :thinking: )
Can you check that the latest commit on master still works in your case ?

Yeah I should have made it clearer - it’s easy to implement a “filter” wher kakoune will run % | kak-spell check - or something, but then we also need to compute the spell ranges options and send the info back to kakoune - not sure how that would work without moving all the logic in the kak script …

How to use this feature? Is there a configuration option to choose alternative backend?

Enchant has 6 backends ← click me

1 Like

Sorry if I’m blind but this page doesn’t say anything about how exactly to configure backends, only states that “Users… can configure which back-ends are used for which languages.”, with links only to APIs.

Yes, it is extremely disjointed merry-go-round of website click and find. Almost put me off using it, so much so all I bookmarked was that sight. Wait for dmere or flick him a message. Thank you for kak-lsp.

Added the -lock flag allows for a second key stroke or skipping through with n.
map global user s ‘: enter-user-mode -lock kak-spell’ -docstring ‘enter spell user mode’

Glad you were in the room dmere :sweat_smile:. Thanks bye :wave:.

How to use this feature? Is there a configuration option to choose an alternative backend?

The answer to that question is a bit complicated, so let’s take an example.

plugins and providers

On my machine, the enchant library was built with the following plugins:

/usr/lib/enchant-2/enchant_aspell.so
/usr/lib/enchant-2/enchant_hspell.so
/usr/lib/enchant-2/enchant_hunspell.so
/usr/lib/enchant-2/enchant_voikko.so

Each plugin implements a provider. In this case, Enchant was built with
the aspell and voikko plugins, so it can use dictionaries coming from those
two providers.

the issue

Now let’s assume you have these packages installed:

  • aspell-en : Aspell dictionary for English
  • aspell-fi : Aspell dictionary for Finnish
  • voikko-fi: Voikko dictionary for Finnish

Enchant has to decide which package to use when spellchecking a Finnish
document - and there are two possible answers here (aspell-fi or voikko-fi).

ordering

In order to solve this, Enchant uses a file named ordering that looks like this:

# /usr/share/enchant/enchant.ordering
*:hunspell,nuspell,aspell
fi:voikko,hunspell,nuspell,aspell
fi_FI:voikko,hunspell,nuspell,aspell
he:hspell,hunspell,nuspell
he_IL:hspell,hunspell,nuspell
tr:zemberek,nuspell
tr_TR:zemberek,nuspell

Since voikko is the first provider listed on the fi line, it will use voikko-fi.

In short, it is Enchant’s job to determine which provider the most suited
for the requested language, not the end user. In that case it makes sense, since
voikko is a provider dedicated to the Finnish language.

But what if you really want to use aspell-fi?

forcing the aspell provider

Well, the first option is to use the set_ordering method on the broker object:

>>> from enchant import Broker
>>> broker = Broker()
>>> broker.set_ordering("fi", "aspell,voikko")
>>> fi_dict = broker.request_dict("fi")
>>> fi_dict.provider.name
'aspell'

kak-spell never uses the set_ordering method on the broker object, so this won’t work
for kak-spell.

But before implementing something like a kak_spell_ordering option, I should point out there’s a much easier solution to the problem at hand: just remove the voikko-fi package from your system!

conclusion

I hope this clarify things - for now I think that implementing kak_spell_ordering
is overkill, unless there’s something about your use case I’m missing.

1 Like

Wow, much better this way!