Advertisement
Guest User

ExtractSentences

a guest
Jun 3rd, 2016
487
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ExtractSentencesbyKeyword
  6. {
  7. class ExtractSentencesbyKeyword
  8. {
  9. static void Main(string[] args)
  10. {
  11. string keyword = Console.ReadLine().ToLower();
  12. List<string> text = Console.ReadLine().Split('.', '!', '?').ToList();
  13.  
  14. for (int sentence = 0; sentence < text.Count; sentence++)
  15. {
  16. string[] result = text[sentence].Split(new char[] { ',', ':', '(', ')', '[', ']', '\"', '\'', '/', '\\', ' ' }, StringSplitOptions.RemoveEmptyEntries);
  17. if (result.Contains(keyword))
  18. {
  19. Console.WriteLine(text[sentence].Trim());
  20. }
  21. }
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement