/// <summary> /// Input dictionary and text matching with result writting to Output in accordance with the formatting /// </summary> public void Check(ITextWriter writer, INeighborsFormater formater, int maxDistance) { this.writer = writer; this.formater = formater; CreateComponent(this.dictionaryBuilder); CreateComponent(this.textBuilder); IText text = (IText)this.textBuilder.GetResult(); IWordDictionary dictionary = (IWordDictionary)this.dictionaryBuilder.GetResult(); for (int i = 0; i != text.LinesCount; i++) { var textLine = text.GetLine(i, out int[] whitespaces); for (int j = 0; j != textLine.Length; j++) { Word word = textLine[j]; var neighbors = dictionary.FindNearestСoincidence(word, maxDistance); var formatedNeighbors = this.formater.FormatNeighbors(word, neighbors); Word editedWord = new Word(formatedNeighbors); textLine[j] = editedWord; } this.writer.WriteLine(textLine, whitespaces); } }