| 1 |
#include "MeaningStream.h" |
| 2 |
#include "Arguments.h" |
| 3 |
|
| 4 |
#include <string> |
| 5 |
#include <iostream> |
| 6 |
#include <vector> |
| 7 |
#include <fstream> |
| 8 |
using namespace std; |
| 9 |
|
| 10 |
int main(int argc, const char** argv) |
| 11 |
{ |
| 12 |
Arguments a(argc, argv); |
| 13 |
|
| 14 |
string wf, mf; |
| 15 |
a.get("--wordsfile", wf, ""); |
| 16 |
a.get("--meanings", mf, ""); |
| 17 |
|
| 18 |
if ((wf == "") || (mf == "")) |
| 19 |
{ |
| 20 |
cerr << "Usage: " << argv[0] << " --wordsfile=[file] --meanings=[file]" << endl; |
| 21 |
return 1; |
| 22 |
} |
| 23 |
|
| 24 |
ifstream win(wf.c_str()); |
| 25 |
vector<string> words; |
| 26 |
words.reserve(30000); |
| 27 |
while(win >> wf) |
| 28 |
words.push_back(wf); |
| 29 |
|
| 30 |
ifstream in(mf.c_str()); |
| 31 |
MeaningStream s(in); |
| 32 |
|
| 33 |
int x; |
| 34 |
while(s >> x) |
| 35 |
{ |
| 36 |
if (x == MeaningStream::EOL) |
| 37 |
cout << endl; |
| 38 |
|
| 39 |
else |
| 40 |
cout << words[x] << ' '; |
| 41 |
} |
| 42 |
|
| 43 |
return 0; |
| 44 |
} |