softcount: tolerate zero ngrams
[vspell.git] / utils / pfs-test.cpp
blobf77d946ad7603785c4fb1581bee6b14efbe41914
1 #include <algorithm>
2 #include <iostream>
3 #include <iterator>
4 #include <spell.h>
5 #include <dag.h>
6 #include <pfs.h>
7 #include <dictionary.h>
9 using namespace std;
11 int main(int argc, char **argv)
13 get_ngram().read(argc == 2 ? argv[1] : "ngram");
14 dic_init();
15 warch.load("wordlist");
17 int count = 0;
18 while (!cin.eof()) {
19 if (++count % 200 == 0) cerr << count << endl;
20 Lattice l;
21 cin >> l;
22 WordDAG dag(&l);
23 Path p;
24 PFS pfs;
25 pfs.search(dag,p);
26 Segmentation seg;
27 if (p.empty() || p.size() <= 2)
28 continue;
29 seg.resize(p.size()-2);
30 copy(p.begin()+1,p.end()-1,seg.begin());
31 seg.we = l.we;
32 cout << seg << endl;
34 return 0;