-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cs
More file actions
49 lines (40 loc) · 1.5 KB
/
main.cs
File metadata and controls
49 lines (40 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace ConsoleApplication1
{
class main
{
public static Dictionary<string, int> stats = new Dictionary<string, int>();
static void Main(string[] args)
{
string txtFolderPath = "C:/corpus";
string[] files = Directory.GetFiles(txtFolderPath, "*", SearchOption.AllDirectories);
int totalFiles = files.Length;
int i = 0; double percent;
foreach (string file in files)
{
i++;
percent = i / ((double) totalFiles / 100);
parser p = new parser(file);
p.getStats();
Console.Clear();
Console.WriteLine("Progress: " + i + "/" + totalFiles + ", " + Math.Round(percent) + "%");
}
Console.WriteLine("\nDone");
Console.WriteLine("Check C:\\corpus_results\\results.txt for results");
Console.ReadKey();
List<KeyValuePair<string, int>> sorted = stats.ToList();
sorted.Sort((firstPair, nextPair) =>
{
return nextPair.Value.CompareTo(firstPair.Value);
});
StreamWriter resultsFile = new StreamWriter("C:/corpus_stats/results.txt");
foreach (KeyValuePair<string, int> pair in sorted)
resultsFile.WriteLine("{0},{1}", pair.Key, pair.Value);
resultsFile.Close();
}
}
}