1 // -*- tab-width: 2 -*-
11 #include <boost/format.hpp>
16 //NgramFractionalStats stats(sarch.get_dict(),2);
18 int main(int argc
,char **argv
)
21 fprintf(stderr
,"Need at least 2 argument.\n");
25 char *oldres
= argv
[1];
26 char *newres
= argv
[2];
32 new WordNode(sarch
["<root>"]) :
33 new FuzzyWordNode(sarch
["<root>"]));
35 cerr
<< "Loading... ";
36 //str = (boost::format("wordlist.wl.%s") % oldres).str().c_str();
38 get_root()->load(str
);
39 str
= (boost::format("ngram.%s") % oldres
).str().c_str();
44 cerr
<< "Ngram loading error..." << endl
;
45 cerr
<< "done" << endl
;
47 sarch
.set_blocked(true);
49 //wfst.set_wordlist(get_root());
52 int i
,ii
,iii
,n
,nn
,nnn
,z
;
54 NgramStats
stats(sarch
.get_dict(),2);
55 while (getline(cin
,s
)) {
58 cerr
<< count
<< endl
;
62 sentences_split(s
,ss
);
63 for (z
= 0;z
< ss
.size();z
++) {
67 if (!st
.get_syllable_count())
71 //cerr << words << endl;
72 Segmentation
seg(words
.we
);
75 wfst
.segment_best_no_fuzzy(words
,seg
);
77 wfst
.segment_best(words
,seg
);
79 //seg.pretty_print(cout,st) << endl;
82 VocabIndex
*vi
= new VocabIndex
[n
+3];
86 for (i
= 0;i
< n
;i
++) {
87 vi
[i
+1] = seg
[i
].node
.node
->get_id();
88 //cerr << "<" << sarch[vi[i]] << "> ";
91 stats
.countSentence(vi
);
95 const WordEntries &we = *words.we;
97 for (i = 0;i < n;i ++) {
98 we[i].node.node->inc_b();
102 for (i = 0;i < n;i ++)
103 seg[i].node.node->inc_a();
108 cerr
<< "Calculating... ";
109 //get_root()->get_next(unk_id)->get_b() = 0;
110 //get_root()->recalculate();
111 ngram
.estimate(stats
);
112 //wfst.enable_ngram(true);
114 cerr
<< "Saving... ";
115 //str = (boost::format("wordlist.wl.%s") % newres).str().c_str();
116 //get_root()->save(str);
118 str
= (boost::format("ngram.%s") % newres
).str().c_str();
123 for (int i = 0;i < 50;i ++) {
126 ofstream ofs(oss.str().c_str());
127 cerr << "Iteration " << i << "... ";
129 cerr << "done" << endl;