00001
00002 #include "moses/Parameter.h"
00003 #include "NBestOptions.h"
00004
00005 namespace Moses
00006 {
00007
00008 NBestOptions::
00009 NBestOptions()
00010 : nbest_size(0)
00011 , factor(20)
00012 , enabled(false)
00013 , print_trees(false)
00014 , only_distinct(false)
00015 , include_alignment_info(false)
00016 , include_feature_labels(true)
00017 , include_segmentation(false)
00018 , include_passthrough(false)
00019 , include_all_factors(false)
00020 {}
00021
00022
00023 bool
00024 NBestOptions::
00025 init(Parameter const& P)
00026 {
00027 const PARAM_VEC *params;
00028 params = P.GetParam("n-best-list");
00029 if (params) {
00030 if (params->size() >= 2) {
00031 output_file_path = params->at(0);
00032 nbest_size = Scan<size_t>( params->at(1) );
00033 only_distinct = (params->size()>2 && params->at(2)=="distinct");
00034 } else {
00035 std::cerr << "wrong format for switch -n-best-list file size [distinct]";
00036 return false;
00037 }
00038 } else nbest_size = 0;
00039
00040 P.SetParameter<size_t>(factor, "n-best-factor", 20);
00041 P.SetParameter(include_alignment_info, "print-alignment-info-in-n-best", false );
00042 P.SetParameter(include_feature_labels, "labeled-n-best-list", true );
00043 P.SetParameter(include_segmentation, "include-segmentation-in-n-best", false );
00044 P.SetParameter(include_passthrough, "print-passthrough-in-n-best", false );
00045 P.SetParameter(include_all_factors, "report-all-factors-in-n-best", false );
00046 P.SetParameter(print_trees, "n-best-trees", false );
00047
00048 enabled = output_file_path.size();
00049 return true;
00050 }
00051
00052 #ifdef HAVE_XMLRPC_C
00053 bool
00054 NBestOptions::
00055 update(std::map<std::string,xmlrpc_c::value>const& param)
00056 {
00057 typedef std::map<std::string, xmlrpc_c::value> params_t;
00058 params_t::const_iterator si = param.find("nbest");
00059 if (si != param.end())
00060 nbest_size = xmlrpc_c::value_int(si->second);
00061 only_distinct = check(param, "nbest-distinct", only_distinct);
00062 enabled = (nbest_size > 0);
00063 return true;
00064 }
00065 #else
00066 bool
00067 NBestOptions::
00068 update(std::map<std::string,xmlrpc_c::value>const& param)
00069 {}
00070 #endif
00071
00072
00073 }