SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. List<string> words = new List<string>();
  2.         cmd = new SqlCommand("Select tokens From tokens_all_comments", connection);
  3.         connection.Open();
  4.         dr = cmd.ExecuteReader();
  5.         while (dr.Read())
  6.         {
  7.             words.Add(dr["tokens"].ToString());
  8.         }
  9.         dr.Close();
  10.         connection.Close();
  11.      
  12. Dictionary<string, int> dictionary = new Dictionary<string, int>();
  13.         foreach (string word in words)
  14.          {
  15.          if (word.Length != 0)
  16.          {
  17.         if ( dictionary.ContainsKey(word) )
  18.         {
  19.          dictionary[word]++;
  20.           }
  21.           else
  22.                 {
  23.                     dictionary[word] = 1;
  24.                 }
  25.  
  26.           }
  27.         }
  28.         var sortedDict = (from entry in dictionary orderby entry.Value descending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top