Debian Codegraph @

data/0.12-dev/gen_pms/engine2.cpp

raw
1 #include <fstream>
2 #include <iostream>
3 #include <vector>
4 #include <string>
5 #include <set>
6 #include <algorithm>
7 #include "fast.h"
8 #include "cleanup.h"
9 #include <ctime>
10 #include <strstream>
11
12
13 void run(istream& fin, ostream& fout, int count)
14 {
15 vector< vector<string> > meanings;
16 meanings.reserve(count+1);
17
18 char buf[64000];
19 int index = 0;
20
21 while(fin.getline(buf, 64000))
22 {
23 if (buf[0] == '#')
24 continue;
25
26 istrstream ss(buf);
27 string str;
28 meanings.push_back( vector<string>() );
29 while(ss >> str)
30 {
31 meanings[index].push_back(str);
32 }
33
34 index++;
35
36 if (index == count)
37 break;
38 }
39
40 vector< vector<string> > output;
41 cleanup(meanings, output);
42
43 for(int i = 0;i < output.size();++i)
44 {
45 if (output[i].empty())
46 continue;
47
48 copy(output[i].begin(), output[i].end(),
49 ostream_iterator<string>(fout, " "));
50 fout << '\n';
51 }
52 }
53
54
55 int main(int argc, const char** argv)
56 {
57 if (argc < 2)
58 {
59 cerr << "Usage: " << argv[0] << " [block-size]" << endl;
60 exit(0);
61 }
62
63 strstream foo;
64 foo << argv[1];
65 int blocksize;
66 foo >> blocksize;
67
68 cout << "Using blocksize " << blocksize << endl;
69
70 string basename = "processed.";
71
72 for(int i = 0;!cin.eof();++i)
73 {
74 strstream ss;
75 ss << basename;
76 ss << i;
77 string file;
78 ss >> file;
79 ofstream fout(file.c_str());
80 run(cin, fout, blocksize);
81 }
82
83 return 0;
84 }
85