-
Notifications
You must be signed in to change notification settings - Fork 15
/
make_wordCountHash.C
52 lines (41 loc) · 1011 Bytes
/
make_wordCountHash.C
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
50
51
52
/*
make a hash set for word (freq>=100, len>=3)
need a source word list that is formated word|freq on each line
need a "path" file that designates a directoy to save the hash set
*/
#include <fstream>
#include "Dmap.h"
#include <Hash.h>
using namespace std;
using namespace iret;
int main(int argc, char **argv)
{
if(argc!=2) {
cout << "Usuage: " << argv[0] << " WordFilename" << endl;
return 1;
}
char * file = argv[1];
ifstream fin(file);
if(!fin) {
cout << "Cannot open " << file << endl;
return 1;
}
strMap Ct;
string word;
long num;
string dummy;
long cnt = 0;
while(getline(fin,word,'|')) {
fin >> num;
getline(fin,dummy); //remove endl;
if( word.size() <3) continue; // want length>=3
if(num < 100) continue; // want freq>=100
Ct.add_count(word.c_str(),num);
cnt++;
}
cout << cnt << " words selected" << endl;
Chash Csh("wrdset3");
Csh.set_path_name("Ab3P");
Csh.create_ctable(Ct,3);
return 0;
}