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

NBestColl.cpp « nbest « SCFG « moses2 - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 38a9ac867ff35ffe63f3eab9062f4884b2427f6e (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
/*
 * NBestColl.cpp
 *
 *  Created on: 24 Aug 2016
 *      Author: hieu
 */
#include <boost/foreach.hpp>
#include "util/exception.hh"
#include "NBestColl.h"
#include "NBests.h"
#include "../Manager.h"
#include "../../System.h"

using namespace std;

namespace Moses2
{
namespace SCFG
{

/////////////////////////////////////////////////////////////
NBestColl::~NBestColl()
{
  BOOST_FOREACH(const Coll::value_type &valPair, m_candidates) {
    NBests *nbests = valPair.second;
    delete nbests;
  }
}

void NBestColl::Add(const SCFG::Manager &mgr, const ArcList &arcList)
{
  NBests &nbests = GetOrCreateNBests(mgr, arcList);
  //cerr << "nbests for " << &nbests << ":";
}

NBests &NBestColl::GetOrCreateNBests(const SCFG::Manager &mgr, const ArcList &arcList)
{
  NBests *ret;
  Coll::iterator iter = m_candidates.find(&arcList);
  if(iter == m_candidates.end()) {
    ret = new NBests(mgr, arcList, *this);
    m_candidates[&arcList] = ret;
  } else {
    ret = iter->second;
  }
  return *ret;
}


}
}