private string findWord(Mistakes mistake, string text) { string result = ""; char[] cAll = text.ToCharArray(); for (int i = mistake.Start; i <= mistake.Ende; i++) { result += cAll[i]; } return(result); }
private void findMistakes() { char[] splitter = { ' ', '.', '!', '?', ',', '-', '*', '/', '(', ')', '\n', ';', ':', '"', '#' , '\'', '\t', '\\', '[', ']', '{', '}', '<', '>' }; string[] separator = { "\r", "\n", " ", "", "-" }; int nID = 0; foreach (HunspellTexte text in lstTexte) { char[] cAll = text.Text.ToCharArray(); int count = cAll.Length; string word = ""; int nOffset = 0; //Leeren der Liste für den Fall des Neuladens. text.Fehler.Clear(); for (int i = 0; i < count; i++) { if (splitter.Contains(cAll[i]) || i == count - 1) { if (i == count - 1) { if (!splitter.Contains(cAll[i])) { nOffset = 1; word += cAll[i]; } } if (!hunspell.Spell(word) && !separator.Contains(word) && !lstIgnoreMistakes.Contains(word)) { Mistakes mistakes = new Mistakes() { Start = i - word.Length + nOffset, Ende = i - 1 + nOffset, ID = nID }; nID++; text.Fehler.Add(mistakes); lstFehler.Add(word); MistakesCounter++; } word = ""; } else { word += cAll[i]; } } } }
private SentenceMistake findSentence(Mistakes mistake, string text) { SentenceMistake sentenceMistake = new SentenceMistake(); char[] cAll = text.ToCharArray(); char[] splitter = { '.', '!', '?' }; int count = cAll.Length; bool gefunden = false; sentenceMistake.Satzbeginn = 0; for (int i = 0; i < count; i++) { if (i > mistake.Start) { gefunden = true; } if (splitter.Contains(cAll[i])) { if (gefunden) { sentenceMistake.Satz += cAll[i]; break; } else { sentenceMistake.Satz = ""; sentenceMistake.Satzbeginn = i + 1; } } else { sentenceMistake.Satz += cAll[i]; } } return(sentenceMistake); }