Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class ExtractSentencesByKeyword
- {
- static void Main()
- {
- char[] seperators = ".!?".ToCharArray();
- //char letter = 'A';
- //char[] seperatorsForSent = new char[177];
- //for (char i = (char)0; i <= 176; i++)
- //{
- // if (!(i >= 65 && i <= 90 || i >= 97 && i<= 122 || i >= 48 && i <= 57 || i == 45))
- // {
- // seperatorsForSent[i] = i;
- // }
- //}
- string word = Console.ReadLine();
- List<string> text = Console.ReadLine().Split(seperators).ToList();
- List<string[]> sentanses = new List<string[]>();
- for (int i = 0; i < text.Count; i++)
- {
- text[i] = text[i].Trim();
- string[] sentans = text[i].Split();
- if (sentans.Contains(word))
- {
- sentanses.Add(sentans);
- }
- }
- foreach (var sentans in sentanses)
- {
- Console.WriteLine(string.Join(" ", sentans));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment