public void FindWordsOfPredeterminedLenght(Text text, int wordLenght) { List <string> words = new List <string>(); foreach (var currentSentence in text.GetQuestionSentences()) { for (int i = 0; i < currentSentence.GetWordsCount(); i++) { var currentElement = currentSentence.GetElementByIndex(i); if (currentElement.SentenceElementType == SentenceElementType.Word && _wordWorker.GetWordLength(currentElement) == wordLenght) { var str = currentElement.Value.ToUpper(); if (!words.Contains(str)) { words.Add(str); } } } } foreach (var result in words) { Console.WriteLine(result); } }
public void DeleteWords(int wordLenght) { //_sententenceElements = _sententenceElements.Select(x => x.seType != SentenceElementType.Word // && _wordWorker.GetWordLength(x) != wordLenght // && !_wordWorker.FirstLetterIsConsonant(x)).ToList(); for (int i = 0; i < _sententenceElements.Count; i++) { if (_sententenceElements[i].SentenceElementType == SentenceElementType.Word && _wordWorker.GetWordLength(_sententenceElements[i]) == wordLenght && _wordWorker.FirstLetterIsConsonant(_sententenceElements[i])) { _sententenceElements.Remove(_sententenceElements[i]); i--; } } }