Created
May 15, 2020 10:44
-
-
Save bjoerntx/24fd52c8159812ba2203733a75c6803b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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