errata-ai / vale

:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
https://vale.sh
MIT License
4.44k stars 152 forks source link

Trying to implement en_GB spelling dictionary #539

Closed ggravlingen closed 1 year ago

ggravlingen commented 1 year ago

Hi,

I'm having a hard time understanding how spell check works with a custom dictionary. Can you please point me in the right direction of what I'm doing wrong here?

This is what I've tried doing so far:

My general/Spelling.yml looks like so:

# https://extensions.libreoffice.org/en/extensions/show/english-dictionaries
# Download and unzip to retrieve the needed files
extends: spelling
message: "'%s' is misspelled"
# Relative to config file
dicpath: ./fixtures/
append: false
level: error
dictionaries:
  - en_GB

This is my .vale.ini:

StylesPath = styles
MinAlertLevel = suggestion

[*]
BasedOnStyles = my, general, Vale

Running this command and I would have expected at least some errors due to the bastardisation of the English language:

(.venv) vscode ➜ /workspaces/python-vale (main ✗) $ vale --config /workspaces/python-vale/.vale.ini "This is quite obvisly a teached afair."
✔ 0 errors, 0 warnings and 0 suggestions in stdin.

I saw somewhere here that you had used the Hunspell command directly so I tried that as well. This throws some errors as expected.

(.venv) vscode ➜ /workspaces/python-vale (main ✗) $ echo "This is quite obvisly a teached afair." | hunspell -d fixtures/en_GB
Hunspell 1.7.0
*
*
*
& obvisly 1 14: obviously
*
& teached 10 24: reached, teaches, teacher, leached, peached, beached, cacheted, cheated, teach, attached
& afair 5 32: afar, fair, affair, a fair, AFAIK
jdkato commented 1 year ago

You don't need to use Hunspell (it doesn't even need to be installed).

Here's what I get when I use your config:

$ vale -v
vale version v2.21.3
$ cat .vale.ini
StylesPath = styles

[*]
BasedOnStyles = Test, Vale
$ ls fixtures
en_GB.aff en_GB.dic
$ vale --config .vale.ini "This is quite obvisly a teached afair."
stdin.txt
 1:15  error  Did you really mean 'obvisly'?  Vale.Spelling 
 1:15  error  'obvisly' is misspelled         Test.Rule     
 1:25  error  Did you really mean 'teached'?  Vale.Spelling 
 1:25  error  'teached' is misspelled         Test.Rule     
 1:33  error  Did you really mean 'afair'?    Vale.Spelling 
 1:33  error  'afair' is misspelled           Test.Rule     

✖ 6 errors, 0 warnings and 0 suggestions in stdin.

where Test.Rule is

extends: spelling
message: "'%s' is misspelled"
# Relative to config file
dicpath: ./fixtures/
append: false
level: error
dictionaries:
  - en_GB

Could you share the output of running vale --config '/workspaces/python-vale/.vale.ini' ls-config?

ggravlingen commented 1 year ago

I wasn't precise on Hunspell, I only installed it to make sure the dictionaries were working.

After implementing your exact settings, I finally got it to work and can work from there. Thank you for getting back to me and for helping me out!