Hi I am making a desktop application (C#) that checks the spelling of the inputted word. I am using Hunspell which I added to my project using NuGet. I have 2 files the aff file and the dic file.
using (Hunspell english = new Hunspell("en_US.aff", "en_US.dic"))
{
bool isExist = english.Spell("THesis");
}
isExist is equal to false because in my .dic file the correct spelling is "thesis". Even I use to .lower() and input proper names the isExist become false.
Can you help me in solving this?
Given that Hunspell does not appear to support case-insensitive spelling checks, you might want to consider adapting your algorithm slightly:
Given THesis
, you could try:
bool isExist = false;
using (Hunspell english = new Hunspell("en_US.aff", "en_US.dic"))
{
TextInfo textInfo = new CultureInfo("en-US",false).TextInfo;
isExist = english.Spell("THesis")
| english.Spell(textInfo.ToLower("THesis")
| english.Spell(textInfo.ToUpper("THesis"))
| english.Spell(textInfo.ToTitleCase("THesis"))
}
This will in turn logically check "THesis", "thesis", "THESIS" and "Thesis" and return true if any of those spellings is valid, courtesy of the logical OR operator.
Similarly for canada
, this would work, as the ToTitleCase()
method would at least guarantee a match.
This should work for most single words (including all caps acronyms).