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

Stacks.cpp « Normal « PhraseBased « moses2 « contrib - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4aab42347ed8294320947ff3c8dcdef55d35a465 (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
/*
 * Stacks.cpp
 *
 *  Created on: 6 Nov 2015
 *      Author: hieu
 */

#include "Stacks.h"
#include "../Manager.h"
#include "../../System.h"

using namespace std;

namespace Moses2
{

namespace NSNormal
{

Stacks::Stacks(const Manager &mgr) :
    m_mgr(mgr)
{
  // TODO Auto-generated constructor stub

}

Stacks::~Stacks()
{
  for (size_t i = 0; i < m_stacks.size(); ++i) {
    delete m_stacks[i];
  }
}

void Stacks::Init(const Manager &mgr, size_t numStacks)
{
  m_stacks.resize(numStacks);
  for (size_t i = 0; i < m_stacks.size(); ++i) {
    m_stacks[i] = new Stack(mgr);
  }
}

std::string Stacks::Debug(const System &system) const
{
  stringstream out;
  for (size_t i = 0; i < GetSize(); ++i) {
    const Stack *stack = m_stacks[i];
    if (stack) {
      out << stack->GetSize() << " ";
    }
    else {
      out << "N ";
    }
  }
  return out.str();
}

void Stacks::Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
    ArcLists &arcLists)
{
  size_t numWordsCovered = hypo->GetBitmap().GetNumWordsCovered();
  //cerr << "numWordsCovered=" << numWordsCovered << endl;
  Stack &stack = *m_stacks[numWordsCovered];
  stack.Add(m_mgr.system, hypo, hypoRecycle, arcLists);
}

}
}