Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace WordCount {
class Program {
static void Main(string[] args) {
var text = File.ReadAllText("135-0.txt").ToLower();
var match = Regex.Match(text, "\\w+");
Dictionary<string, int> freq = new Dictionary<string, int>();
while (match.Success) {
string word = match.Value;
if (freq.ContainsKey(word)) {
freq[word]++;
} else {
freq.Add(word, 1);
}
match = match.NextMatch();
}
Console.WriteLine("Rank Word Frequency");
Console.WriteLine("==== ==== =========");
int rank = 1;
foreach (var elem in freq.OrderByDescending(a => a.Value).Take(10)) {
Console.WriteLine("{0,2} {1,-4} {2,5}", rank++, elem.Key, elem.Value);
}
}
}
}