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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Collections;
using System.Threading.Tasks;

namespace tfidf
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, int> df = new Dictionary<string, int>();
string[] dic;

string wtemp;
StreamReader sr = new StreamReader(@"..\..\Dictionary225.txt");
while ((wtemp = sr.ReadLine()) != null)
{
df.Add(wtemp, 0);
}
sr.Close();

dic = df.Keys.ToArray();

StreamReader sr2 = new StreamReader(@"..\..\corpus4.txt");
while ((wtemp = sr2.ReadLine()) != null)
{
//.NET FRAMEWORK 4 ONLY
Parallel.ForEach(dic, key =>
{
int j = 0;
while ((j = wtemp.IndexOf(key, j)) > -1)
{
df[key]++;
j++;
}
});
}
sr2.Close();
}
}
}