Added record/replay mode to sc-train to speed up the process
[vspell.git] / utils / lattice-test.cpp
blob8d707cccd3f9c91d2cebbd35822a050d9afd863b
1 #include "propername.h"
2 #include "tokenize.h"
3 #include <algorithm>
4 #include <iostream>
5 #include <iterator>
6 #include <spell.h>
7 #include <dictionary.h>
9 using namespace std;
11 int main(int argc, char **argv)
13 bool revert = false;
14 bool use_fuzzy = false;
15 int revert_level = 0;
16 for (int i = 1;i < argc;i ++) {
17 if (string(argv[i]) == "-r")
18 revert = true;
19 if (string(argv[i]) == "--sentence" || string(argv[i]) == "2")
20 revert_level = 2;
21 if (string(argv[i]) == "--token" || string(argv[i]) == "1")
22 revert_level = 1;
23 if (string(argv[i]) == "--fuzzy")
24 use_fuzzy = true;
26 dic_init();
27 warch.load("wordlist");
29 int count = 0;
30 while (!cin.eof()) {
31 if (++count % 200 == 0) cerr << count << endl;
32 Lattice words;
33 set<WordEntry> wes;
34 if (revert) {
35 cin >> words;
36 switch (revert_level) {
37 case 0: cout << words << endl; break;
38 case 1: cout << *words.st << endl; break;
39 case 2: cout << words.st->get() << endl; break;
42 else {
43 boost::shared_ptr<Sentence> st(new Sentence(cin));
44 WordStateFactories factories;
45 ExactWordStateFactory exact;
46 LowerWordStateFactory lower;
47 FuzzyWordStateFactory fuzzy;
48 factories.push_back(&exact);
49 factories.push_back(&lower);
50 if (use_fuzzy)
51 factories.push_back(&fuzzy);
52 words.pre_construct(st,wes,factories);
53 mark_proper_name(*st,wes);
54 words.post_construct(wes);
55 cout << words << endl;
58 return 0;