From b380e662e38e58404e9d2b0e68fa69348e6aa72d Mon Sep 17 00:00:00 2001 From: redpony Date: Sun, 14 Nov 2010 21:56:39 +0000 Subject: rescoring support git-svn-id: https://ws10smt.googlecode.com/svn/trunk@719 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/decoder.cc | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'decoder') diff --git a/decoder/decoder.cc b/decoder/decoder.cc index 2a8043db..065510a7 100644 --- a/decoder/decoder.cc +++ b/decoder/decoder.cc @@ -347,12 +347,14 @@ DecoderImpl::DecoderImpl(po::variables_map& conf, int argc, char** argv, istream ("scfg_no_hiero_glue_grammar,n", "No Hiero glue grammar (nb. by default the SCFG decoder adds Hiero glue rules)") ("scfg_default_nt,d",po::value()->default_value("X"),"Default non-terminal symbol in SCFG") ("scfg_max_span_limit,S",po::value()->default_value(10),"Maximum non-terminal span limit (except \"glue\" grammar)") + ("quiet", "Disable verbose output") ("show_config", po::bool_switch(&show_config), "show contents of loaded -c config files.") ("show_weights", po::bool_switch(&show_weights), "show effective feature weights") ("show_joshua_visualization,J", "Produce output compatible with the Joshua visualization tools") ("show_tree_structure", "Show the Viterbi derivation structure") ("show_expected_length", "Show the expected translation length under the model") ("show_partition,z", "Compute and show the partition (inside score)") + ("show_partition_as_translation", "Output the partition to STDOUT instead of a translation") ("show_cfg_search_space", "Show the search space as a CFG") ("show_features","Show the feature vector for the viterbi translation") ("prelm_density_prune", po::value(), "Applied to -LM forest just before final LM rescoring: keep no more than this many times the number of edges used in the best derivation tree (>=1.0)") @@ -434,7 +436,8 @@ DecoderImpl::DecoderImpl(po::variables_map& conf, int argc, char** argv, istream cerr<<" "<NotifySourceParseFailure(smeta); o->NotifyDecodingComplete(smeta); + if (conf.count("show_partition_as_translation")) { + cout << "-Inf" << endl << flush; + } return false; } @@ -784,7 +790,7 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) { if (sample_max_trans) { MaxTranslationSample(&forest, sample_max_trans, conf.count("k_best") ? conf["k_best"].as() : 0); } else { - if (kbest) { + if (kbest && !has_ref) { //TODO: does this work properly? oracle.DumpKBest(sent_id, forest, conf["k_best"].as(), unique_kbest,"-"); } else if (csplit_output_plf) { @@ -902,12 +908,21 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) { } } if (conf.count("graphviz")) forest.PrintGraphviz(); + if (kbest) + oracle.DumpKBest(sent_id, forest, conf["k_best"].as(), unique_kbest,"-"); + if (conf.count("show_partition_as_translation")) { + const prob_t z = Inside(forest); + cout << log(z) << endl << flush; + } } else { o->NotifyAlignmentFailure(smeta); if (!SILENT) cerr << " REFERENCE UNREACHABLE.\n"; if (write_gradient) { cout << endl << flush; } + if (conf.count("show_partition_as_translation")) { + cout << "-Inf" << endl << flush; + } } } o->NotifyDecodingComplete(smeta); -- cgit v1.2.3