Closed nschloe closed 2 years ago
That's because the language is set (en
by default), and case_sensitive
is ignored if language is set (as per the docstring).
Thanks for the reply! Is there way to get
{'FBI'}
{}
from the above code at all? (If language=None
, both seem to be ignored.)
That is likely because you didn't add a dictionary. What dictionary did you add?
Can you try something like this? This should work, I am not at a location to run it myself to verify no typos!
from spellchecker import SpellChecker
spell = SpellChecker(language=None, case_sensitive=True)
spell.word_frequency.add("FBI")
print("FBI" in spell)
print("fbi" in spell)
Ah wait, when using language=None
, it actually only spellchecks words that I put in manually? That's not good enough for me. Is there no way to use a case-sensitive English dictionary?
To use a case_sensitive dictinoary, you will need to build it yourself as the default dictionaries are case-insensitive. There are lots of ways to build dictionaries, and they are not manually. I only used that to ensure that there wasn't a bug. You can find the different ways to build a custom dictionary in the documentation on building a new dictionary or in the GitHub Discussion #90.
Either way, there are reasons why the default dictionaries are not capitalized:
The
vs. the
) since the same word may be capitalized, say due to being the first word in the sentence. Just some thoughts on it; good luck!
Thanks for the info!
In a case-sensitive dictionary, I would expect
'FBI'
to be known and'fbi'
to be unknown. However, both cases give me'fbi'
as known: