summaryrefslogtreecommitdiff
path: root/decoder/viterbi.cc
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-01 23:08:34 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-01 23:08:34 +0000
commit70114f58324ff60de3d77a42d299e3bcf2c37450 (patch)
tree919088efabf013229c7acb5bd4de4f8045aa89b7 /decoder/viterbi.cc
parente3aebfc755f7f1ceefe1eafcfff23bee9d08d2f3 (diff)
factor forest stats (show size post pruning, and portion kept) and cdec --scale_prune_srclen
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@96 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/viterbi.cc')
-rw-r--r--decoder/viterbi.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/decoder/viterbi.cc b/decoder/viterbi.cc
index 582dc5b2..7f52d08c 100644
--- a/decoder/viterbi.cc
+++ b/decoder/viterbi.cc
@@ -6,6 +6,23 @@
using namespace std;
+std::string viterbi_stats(Hypergraph const& hg, std::string const& name, bool estring, bool etree)
+{
+ ostringstream o;
+ o << hg.stats(name);
+ if (estring) {
+ vector<WordID> trans;
+ const prob_t vs = ViterbiESentence(hg, &trans);
+ o<<name<<" Viterbi: "<<log(vs)<<endl;
+ o<<name<<" Viterbi: "<<TD::GetString(trans)<<endl;
+ }
+ if (etree) {
+ o<<name<<" tree: "<<ViterbiETree(hg)<<endl;
+ }
+ return o.str();
+}
+
+
string ViterbiETree(const Hypergraph& hg) {
vector<WordID> tmp;
const prob_t p = Viterbi<vector<WordID>, ETreeTraversal, prob_t, EdgeProb>(hg, &tmp);