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

Stack.h « CubePruningMiniStack « PhraseBased « moses2 « contrib - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ed7025d1b2a98690152546e8b2e4a73a9c924890 (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
69
70
71
72
73
74
75
76
/*
 * Stack.h
 *
 *  Created on: 24 Oct 2015
 *      Author: hieu
 */
#pragma once
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
#include <deque>
#include "../Hypothesis.h"
#include "../../TypeDef.h"
#include "../../Vector.h"
#include "../../MemPool.h"
#include "../../Recycler.h"
#include "../../HypothesisColl.h"
#include "../../legacy/Util2.h"

namespace Moses2
{

class Manager;
class HypothesisBase;
class ArcLists;

namespace NSCubePruningMiniStack
{

class Stack
{
protected:

public:
  typedef std::pair<const Bitmap*, size_t> HypoCoverage;
  // bitmap and current endPos of hypos

  typedef boost::unordered_map<HypoCoverage, Moses2::HypothesisColl*,
      boost::hash<HypoCoverage>, std::equal_to<HypoCoverage>,
      MemPoolAllocator<std::pair<HypoCoverage, Moses2::HypothesisColl*> > > Coll;

  Stack(const Manager &mgr);
  virtual ~Stack();

  size_t GetHypoSize() const;

  Coll &GetColl()
  {
    return m_coll;
  }
  const Coll &GetColl() const
  {
    return m_coll;
  }

  void Add(Hypothesis *hypo, Recycler<HypothesisBase*> &hypoRecycle,
      ArcLists &arcLists);

  Moses2::HypothesisColl &GetMiniStack(const HypoCoverage &key);

  const Hypothesis *GetBestHypo() const;
  void Clear();

  void DebugCounts();

protected:
  const Manager &m_mgr;
  Coll m_coll;

  std::deque<Moses2::HypothesisColl*, MemPoolAllocator<Moses2::HypothesisColl*> > m_miniStackRecycler;

};

}

}