blob: 8cd386a08db26f1675f63a13527673fced34dff4 (
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
|
/*
* 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;
}
}
}
|