Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created May 15, 2020 10:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjoerntx/24fd52c8159812ba2203733a75c6803b to your computer and use it in GitHub Desktop.
Save bjoerntx/24fd52c8159812ba2203733a75c6803b to your computer and use it in GitHub Desktop.
[HttpGet]
[Route("Check")]
public List<IncorrectWordModel> Check(string text, string language = "en_US")
{
if (text == null)
return null;
// create a new spell checking engine
TXTextControl.Proofing.TXSpell spell = new TXTextControl.Proofing.TXSpell();
spell.Create();
TXTextControl.Proofing.OpenOfficeDictionary dict =
new OpenOfficeDictionary(@"Dictionaries\en_US.dic");
spell.Dictionaries.Add(dict);
spell.Check(text, new System.Globalization.CultureInfo(language));
List<IncorrectWordModel> lIncorrectWords = new List<IncorrectWordModel>();
var incorrectWords = spell.IncorrectWords;
if (incorrectWords == null)
return null;
foreach (IncorrectWord word in incorrectWords)
{
lIncorrectWords.Add(new IncorrectWordModel()
{
Text = word.Text,
Index = word.Index,
IsDuplicate = word.IsDuplicate,
Length = word.Length,
Start = word.Start
});
}
return lIncorrectWords;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment