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

Updater.cpp « server « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 095af383866f1710ae85e18e9e99f8a78cd36dfd (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
// -*- mode: c++; indent-tabs-mode: nil; tab-width:2  -*-
#include "Updater.h"

namespace MosesServer
{
using namespace Moses;
using namespace std;

Updater::
Updater()
{
  // signature and help strings are documentation -- the client
  // can query this information with a system.methodSignature and
  // system.methodHelp RPC.
  this->_signature = "S:S";
  this->_help = "Updates stuff";
}

void
Updater::
execute(xmlrpc_c::paramList const& paramList,
        xmlrpc_c::value *   const  retvalP)
{
#if PT_UG
  const params_t params = paramList.getStruct(0);
  breakOutParams(params);
  Mmsapt* pdsa = reinterpret_cast<Mmsapt*>(PhraseDictionary::GetColl()[0]);
  pdsa->add(m_src, m_trg, m_aln);
  XVERBOSE(1,"Done inserting\n");
  *retvalP = xmlrpc_c::value_string("Phrase table updated");
#endif
};

void
Updater::
breakOutParams(const params_t& params)
{
  params_t::const_iterator si = params.find("source");
  if(si == params.end())
    throw xmlrpc_c::fault("Missing source sentence",
                          xmlrpc_c::fault::CODE_PARSE);
  m_src = xmlrpc_c::value_string(si->second);
  XVERBOSE(1,"source = " << m_src << endl);
  si = params.find("target");
  if(si == params.end())
    throw xmlrpc_c::fault("Missing target sentence",
                          xmlrpc_c::fault::CODE_PARSE);
  m_trg = xmlrpc_c::value_string(si->second);
  XVERBOSE(1,"target = " << m_trg << endl);
  if((si = params.find("alignment")) == params.end())
    throw xmlrpc_c::fault("Missing alignment", xmlrpc_c::fault::CODE_PARSE);
  m_aln = xmlrpc_c::value_string(si->second);
  XVERBOSE(1,"alignment = " << m_aln << endl);
  m_bounded  = ((si = params.find("bounded")) != params.end());
  m_add2ORLM = ((si = params.find("updateORLM")) != params.end());
};

}