Hello everyone, there is a task to divide the text into sentences, and them into words and then convert everything to lower case. And all the conditions seem to be fulfilled, but when you send text with quotes, for example, "test", the task does not work, although the quotes are listed in delimiters. Can you tell me the reason?

using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace TextAnalysis { static class SentencesParserTask { public static List<List<string>> ParseSentences(string text) { var separ = new[] { '.', '!', '?', ':', ';', '(', ')' }; var stringList = new List<string>(); var sentencesList = new List<List<string>>(); string[] sentences = text.Split(separ); stringList = sentences.ToList(); var wordsList = new List<string>(); foreach (var item in stringList) { //String pattern = @"([\d,]+)(\s*)(\r\n(\w+))"; wordsList = (item.Split(new[] {' ', ',', '\t','\r','\n', '^','#','*','@','$','%','&','+','-','/', '1', '=', '\"'}).Where(x=>Check(x)).ToList()); //wordsList = Regex.Split(item, pattern).Where(x => Check(x)).ToList(); List<string> lowerCase = wordsList.Select(d => d.ToLower()).ToList(); if (!(lowerCase.Count() == 0) ){ sentencesList.Add(lowerCase); } } return sentencesList; } private static bool Check(string x) { return x.Length > 0 && x.Where(c => char.IsLetter(c)).Count() > 0; } } } 
  • This is how it works: string text = "english words \" test \ ""; var result = SentencesParserTask.ParseSentences (text); - Igor Ilyichyov

0