단어가 잘못 입력되어 있고 두 단어의 조합으로 보이는 단어를 자동으로 수정하는 방법을 찾고 있습니다. 예를 들어 "considerofof"는 "고려 대상"이어야합니다. 모든 리드 또는 예제는 크게 감사하겠습니다. 감사!C# 맞춤법이 틀린 단어 문자열에 대한 WPF 맞춤법 검사기.
-2
A
답변
4
맞춤법 실수의 반복이 시도 :
이TextBox tb = new TextBox();
tb.SpellCheck.IsEnabled = true;
tb.Text = @"I am looking for ways to automatically fix a word if the word is miss spelled and seems to be a combination of two words. For example ""considerationof"" should be ""consideration of"". Any lead or any example will be greatly appreciated. Thanks!";
var spellingErrorIndex = tb.Text.Length;
do
{
var spellingError = tb.GetSpellingError(spellingErrorIndex);
if (spellingError != null)
{
var suggestions = spellingError.Suggestions; //suggests "consideration of"
spellingError.Correct(suggestions.First());
}
spellingErrorIndex = tb.GetNextSpellingErrorCharacterIndex(spellingErrorIndex, LogicalDirection.Backward);
} while (spellingErrorIndex >= 0);
실행이 후 tb.Text
의 값은
"나는 단어 인 경우 자동으로 단어를 해결하는 방법을 찾고있다 철자가 틀렸고 두 단어의 조합 인 것 같습니다. 예를 들어 \의 "고려"는 \ "고려 \"이어야합니다. 모든 리드 또는 예제는 크게 감사하겠습니다. 감사합니다. "
첫 제안을 "자동 수정"합니다. 그것이 궁극적으로 당신이 원하는 것인지 아닌지를 결정해야합니다.
TextChanged
이벤트에 넣는 것은 좋지 않을 것입니다. 단어를 수정하기 전에 단어를 수정하고 싶지는 않습니다. 어쩌면 LostFocus
과 같은 것이 더 적절할 것입니다.
+1
감사합니다. – inavnacorp
ASP.NET, Winforms, WPF에 있나요? ... – Brad
WPF 응용 프로그램입니다. – inavnacorp
본 적이 있습니까? https://msdn.microsoft.com/en-us/library/system.windows.controls.spellcheck(v=vs.110).aspx – Brad