public void Edit(Object obj) { if (m_editor != null) { m_editor.Edit(obj); } }
/// <inheritdoc cref="ISpellChecker.Check"/> public void Check() { foreach (var textLine in _inputReader.GetTextLines()) { StringBuilder sb = new StringBuilder(textLine.Length); if (!string.IsNullOrWhiteSpace(textLine)) { var textWords = textLine.Split(' '); foreach (var textWord in textWords) { if (_dictionary.ContainsWord(textWord)) { sb.Append($"{textWord} "); } else { var dictionaryWords = _dictionary.GetDictionaryValuesByWord(textWord); sb.Append($"{_editor.Edit(textWord, dictionaryWords)} "); } } _outputWriter.WriteLine(sb.ToString().TrimEnd(' ')); } else { return; } } }
public void Editor_Edit(string word, string dictionary, string expectedResult) { //Arrange //Act var result = _editor.Edit(word, dictionary.Split(' ')); //Assert result.ShouldBe(expectedResult); }
public static KDNode <T> Create <T>(HPoint key, IEditor <T> editor) { KDNode <T> t = new KDNode <T>(key, editor.Edit(default(T))); if (Equals(t.value, default(T))) { t.deleted = true; } return(t); }
// Method ins translated from 352.ins.c of Gonnet & Baeza-Yates public static int Edit <T>(HPoint key, IEditor <T> editor, KDNode <T> t, int lev, int k) { KDNode <T> next_node; int nextLev = (lev + 1) % k; lock (t) { if (key.Equals(t.key)) { bool wasDeleted = t.deleted; t.value = editor.Edit(t.deleted ? default(T) : t.value); t.deleted = (t.value == null); if (t.deleted == wasDeleted) { return(0); } else if (wasDeleted) { return(-1); } return(1); } else if (key.Coord[lev] > t.key.Coord[lev]) { next_node = t.right; if (next_node == null) { t.right = Create(key, editor); return(t.right.deleted ? 0 : 1); } } else { next_node = t.left; if (next_node == null) { t.left = Create(key, editor); return(t.left.deleted ? 0 : 1); } } } return(Edit(key, editor, next_node, nextLev, k)); }