/// <summary> /// In some sentence of the text, replace words of a given length with the specified substring, /// the length of which may not coincide with the length of the word /// </summary> /// <param name="sentence">All text sentences</param> /// <param name="length">Word length</param> /// <param name="newWord">Word to replace</param> public void ReplaceWords(ISentence sentence, int length, string newWord) { foreach (var word in sentence.Words.Where(x => x is IWord word && word.Count == length).ToList()) { sentence.Replace(word, new Word(newWord)); } }