1 // -*- tab-width: 2 -*-
10 #include "softcount.h"
11 #include "propername.h"
12 #include <boost/format.hpp>
16 int main(int argc
,char **argv
)
21 bool first_count
= false;
22 bool record_sc
= false;
23 bool replay_sc
= false;
25 const char *wordlist
= NULL
;
30 if (argc
>= 2 && !strcmp(argv
[argi
], "--wordlist")) {
31 wordlist
= argv
[argi
+1];
35 if (argc
>= 1 && !strcmp(argv
[argi
],"--record")) {
41 if (argc
>= 1 && !strcmp(argv
[argi
],"--replay")) {
49 if (!get_ngram().read(str
)) {
51 cerr
<< "Ngram loading error..." << endl
;
57 cerr
<< "First count " << endl
;
59 if (!warch
.load(first_count
? wordlist
: NULL
))
60 cerr
<< "Error loading " << wordlist
<< endl
;
62 get_ngram().set_blocked(true);
66 while (!feof(stdin
)) {
67 if (++count
% 200 == 0)
68 fprintf(stderr
,"%d\n",count
);
69 if (SoftCounter::replay2(stdin
,stdout
,count
-1,first_count
) == -2)
75 if (++count
% 200 == 0)
76 cerr
<< count
<< endl
;
82 if (trigram
&& !record_sc
) {
83 dagw2
= new WordDAG2(&dagw
);
86 //sc.count(words,stats);
88 SoftCounter::record2(*dag
,stdout
,count
-1);
91 SoftCounter::count_dag(*dag
,cout
,count
-1,first_count
);
92 if (trigram
&& !record_sc
)
93 delete (WordDAG2
*)dag
;
94 get_ngram().clear_oov();