Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2014
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. try
  2. {
  3. StreamReader sr = new StreamReader(@"C:Readfile.txt");
  4. text = sr.ReadToEnd();
  5.  
  6. string textData = Regex.Replace(text, @"[^0-9a-zA-Z]+", " ");
  7.  
  8. char[] whitespace = new char[] { ' ', 't' };
  9. string[] data = textData.Split(whitespace);
  10. int i = 1;
  11.  
  12. while (i < data.Length)
  13. {
  14. st = data[i];
  15.  
  16. string[] source = text.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' }, StringSplitOptions.RemoveEmptyEntries);
  17.  
  18. var matchQuery = from word in source
  19. where word.ToLowerInvariant() == st.ToLowerInvariant()
  20. select word;
  21.  
  22. int wordCount = matchQuery.Count();
  23. k += wordCount + ": " + st + "n";
  24. //MessageBox.Show(k);
  25. i++;
  26. }
  27. StreamWriter sr4 = new StreamWriter(@"C:WhatFound.txt");
  28. sr4.Write(k);
  29.  
  30. }
  31. catch (Exception ce)
  32. {
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement