Welcome to mirror list, hosted at ThFree Co, Russian Federation.

NBestOptions.cpp « parameters « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3000f49df461e6a2b6f5027bc3479b0b69cb5c86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// -*- mode: c++; indent-tabs-mode: nil; tab-width: 2 -*-
#include "moses/Parameter.h"
#include "NBestOptions.h"

namespace Moses
{

  NBestOptions::
  NBestOptions()
    : nbest_size(0)
    , factor(20)
    , enabled(false)
    , print_trees(false)
    , only_distinct(false)
    , include_alignment_info(false)
    , include_feature_labels(true)
    , include_segmentation(false)
    , include_passthrough(false)
    , include_all_factors(false)
  {}


bool
NBestOptions::
init(Parameter const& P)
{
  const PARAM_VEC *params;
  params = P.GetParam("n-best-list");
  if (params) {
    if (params->size() >= 2) {
      output_file_path = params->at(0);
      nbest_size = Scan<size_t>( params->at(1) );
      only_distinct = (params->size()>2 && params->at(2)=="distinct");
    } else {
      std::cerr << "wrong format for switch -n-best-list file size [distinct]";
      return false;
    }
  } else nbest_size = 0;

  P.SetParameter<size_t>(factor, "n-best-factor", 20);
  P.SetParameter(include_alignment_info, "print-alignment-info-in-n-best", false );
  P.SetParameter(include_feature_labels, "labeled-n-best-list", true );
  P.SetParameter(include_segmentation, "include-segmentation-in-n-best", false );
  P.SetParameter(include_passthrough, "print-passthrough-in-n-best", false );
  P.SetParameter(include_all_factors, "report-all-factors-in-n-best", false );
  P.SetParameter(print_trees, "n-best-trees", false );

  enabled = output_file_path.size();
  return true;
}
  
#ifdef HAVE_XMLRPC_C
bool 
NBestOptions::
update(std::map<std::string,xmlrpc_c::value>const& param)
{
  typedef std::map<std::string, xmlrpc_c::value> params_t;
  params_t::const_iterator si = param.find("nbest");
  if (si != param.end())
    nbest_size = xmlrpc_c::value_int(si->second);
  only_distinct = check(param, "nbest-distinct", only_distinct);
  enabled = (nbest_size > 0);
  return true;
}
#endif


} // namespace Moses