protected void CountSentences()
        {
            var text      = TextFileFetcher.GetTextFileString();
            var sentences = text.Where((t, i) => endCharacters.Contains(t) && text[i + 1] == ' ' ||
                                       endCharacters.Contains(t) && text[i + 1] == '\n'
                                       ).Count();

            Writer.WriteMessege($"Value of sentences in file is {sentences}");
        }
Exemple #2
0
        public void Activate()
        {
            String        text      = Regex.Replace(TextFileFetcher.GetTextFileString(), @"(\d|_)+", "");
            List <String> wordsList = Regex.Split(text, @"(\ )",
                                                  RegexOptions.IgnoreCase,
                                                  TimeSpan.FromMilliseconds(500)).ToList();
            Regex         rgx           = new Regex(@"^(\ |:)$");
            List <String> wordsOnlyList = wordsList.FindAll(x => !rgx.IsMatch(x) && x != "");

            Writer.WriteMessege("Text words count: {0}\n", wordsOnlyList.Count);
        }
        public void Activate()
        {
            string text    = TextFileFetcher.GetTextFileString();
            int    counter = 0;

            foreach (var letter in text)
            {
                if (punctuationMarksList.Contains(letter))
                {
                    counter++;
                }
            }
            Writer.WriteMessege($"Number of punctuation marks: {counter}");
        }