Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<string> words = new List<string>();
- cmd = new SqlCommand("Select tokens From tokens_all_comments", connection);
- connection.Open();
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- words.Add(dr["tokens"].ToString());
- }
- dr.Close();
- connection.Close();
- Dictionary<string, int> dictionary = new Dictionary<string, int>();
- foreach (string word in words)
- {
- if (word.Length != 0)
- {
- if ( dictionary.ContainsKey(word) )
- {
- dictionary[word]++;
- }
- else
- {
- dictionary[word] = 1;
- }
- }
- }
- var sortedDict = (from entry in dictionary orderby entry.Value descending select entry).ToDictionary(pair => pair.Key, pair => pair.Value);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement