Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to add "wrong" words to dictionary? #66

Closed
bittorf opened this issue Apr 25, 2016 · 16 comments
Closed

how to add "wrong" words to dictionary? #66

bittorf opened this issue Apr 25, 2016 · 16 comments

Comments

@bittorf
Copy link

bittorf commented Apr 25, 2016

i want to add 'churchs' as a good word (a shoebrand!)
to my private dictionary, but codespell always want
to correct it with churchs->churches

what is the proposed way to do this?

@thdot
Copy link
Contributor

thdot commented Jan 2, 2017

You could use the --exclude-file option to exclude the lines containing the good word explicitly.
Not the most elegant way, I know.

@bittorf
Copy link
Author

bittorf commented Jan 4, 2017

a more elegant solution would be a comment-statement in the line with e.g.

codespell: churchs

@lucasdemarchi
Copy link
Collaborator

@bittorf there isn't a way to do that right now. I think it would be reasonable to add a new option to pass a file with "ignore-words", or to extend the dictionary format to allow passing words as good ones.

For the first option it would be something like:
codespell --ignore-words /path/to/good/dictionary.txt

While for the second we would support in the dictionary a syntax like:
-churchs

So you could use something like thi:
codespell -D - -D /path/to/dictionary/extensions/including/good/words

@anatol @pabs3 @Eric89GXL @thdot thoughts

@bittorf
Copy link
Author

bittorf commented Jan 4, 2017

@lucasdemarchi that is not the way i like it:

the given example is real ("churchs") but of course i do not want
to loose real occurences of a misspelled "church". think of a large file,
where only 1 thing should be overridden...

@lucasdemarchi
Copy link
Collaborator

lucasdemarchi commented Jan 4, 2017 via email

@thdot
Copy link
Contributor

thdot commented Jan 4, 2017

I agree with Lucas, adding comments into the code to influence codespell isn't a sustainable way. Personally I like the idea to extend the dictionary syntax, but a word exclude file is fine for me as well.

@bittorf: if you want to ignore just one occurrence of "churchs" I think the --exclude-file option is a good way to achieve that.

@bittorf
Copy link
Author

bittorf commented Jan 4, 2017

@thdot - i can work with the --exclude-file approach, but it is not elegant. having statements in the file is an old and good way to talk with a compiler. see e.g. GCC or 'shellcheck': https://github.com/koalaman/shellcheck/wiki/Directive

having extra files describing an issue feels like code duplication. what is if a line moves up or down? i have to tweak my 2nd file also...

@luzpaz
Copy link
Collaborator

luzpaz commented Feb 27, 2017

please integrate a codespell --ignore-words /path/to/good/dictionary.txt

@larsoner
Copy link
Member

Fixed by #100

@bittorf
Copy link
Author

bittorf commented Oct 17, 2018

i still think, that a 'directive' directly above the false positive would be a better solution, e.g.

...
# codespell ignore=churchs
echo "a wrong word: churchs (a shoebrand) and a good word: churches"
...

codespell does not need knowledge about how to detect comments in language XY:
it only must check, if in the line above is a directive "codespell ignore=..."

@luzpaz
Copy link
Collaborator

luzpaz commented Oct 17, 2018

@bittorf
use the -L flag. Try this:
echo "churchs, churches" | codespell -L churchs -
then try
echo "churchs, churches" | codespell -

@bittorf
Copy link
Author

bittorf commented Oct 22, 2018

The L flag is not enough:
This way you ignore the wrong word "churchs" in the whole file.

Having a "directive" in the file, you can ignore just a single occurrence
and the knowledge about this special situation is directly at the correct place.

@discordianfish
Copy link

I agree, a directive would be great! I want to be specific about where to ignore what.

@alex-zenml
Copy link

@bittorf use the -L flag. Try this: echo "churchs, churches" | codespell -L churchs - then try echo "churchs, churches" | codespell -

I'm not quite sure why this example doesn't follow the pattern:

echo "DotA" | codespell -L DotA -

I get an error that is seemingly inextinguishable.

@peternewman
Copy link
Collaborator

peternewman commented Feb 7, 2022

I'm not quite sure why this example doesn't follow the pattern:

echo "DotA" | codespell -L DotA -

I get an error that is seemingly inextinguishable.

Try this @alex-zenml :
echo "DotA" | codespell -L dota -

-L WORDS, --ignore-words-list WORDS
comma separated list of words to be ignored by
codespell. Words are case sensitive based on how they
are written in the dictionary file

@bittorf we've also got this now:

  -x FILE, --exclude-file FILE
                        FILE with lines that should not be checked for errors
                        or changed

The issue with comment directives, is e.g. you can't do them within some Pydoc or a Doxygen block or whatever (so it can't always be the line before), and you can then never write codespell ignore= without it ignoring something, i.e. you can't ever write a comment about that behaviour.

@12rambau
Copy link
Contributor

just an update that since #2400 it's now possible to add inline ignore comments.

Clumsy-Coder added a commit to Clumsy-Coder/astronvim-config-v4 that referenced this issue Aug 9, 2024
  ## what
  - use `codespell` ONLY for diagnostics

  ## how
  - check
    - codespell-project/codespell#66 (comment)

  ## why
  - by default the formatter is also enabled, sometimes overwriting
    words that misspelled in code

  ## where
  - ./lua/plugins/none-ls.lua

  ## usage

  ## commit id, issue or pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants