File size: 1,895 Bytes
fd49381
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
 * TargetPhraseImpl.h
 *
 *  Created on: 23 Oct 2015
 *      Author: hieu
 */

#pragma once

#include <iostream>
#include "../Phrase.h"
#include "../PhraseImplTemplate.h"
#include "../TargetPhrase.h"
#include "../MemPool.h"
#include "../SubPhrase.h"
#include "../AlignmentInfoCollection.h"
#include "Word.h"

namespace Moses2
{
class Scores;
class Manager;
class System;
class PhraseTable;
class AlignmentInfo;

namespace SCFG
{

class TargetPhraseImpl: public Moses2::TargetPhrase<SCFG::Word>
{
public:
  typedef Moses2::TargetPhrase<SCFG::Word> Parent;

  SCFG::Word lhs;

  static TargetPhraseImpl *CreateFromString(MemPool &pool,
      const PhraseTable &pt, const System &system, const std::string &str);

  TargetPhraseImpl(MemPool &pool, const PhraseTable &pt, const System &system,
                   size_t size);
  //TargetPhraseImpl(MemPool &pool, const System &system, const TargetPhraseImpl &copy);

  virtual ~TargetPhraseImpl();

  const AlignmentInfo &GetAlignNonTerm() const {
    return *m_alignNonTerm;
  }

  void SetAlignNonTerm(const AlignmentInfo &alignInfo) {
    m_alignNonTerm = &alignInfo;
  }

  void SetAlignmentInfo(const std::string &alignString);

  SCORE GetFutureScore() const {
    return m_scores->GetTotalScore() + m_estimatedScore;
  }

  virtual SCORE GetScoreForPruning() const {
    return GetFutureScore();
  }

  void SetEstimatedScore(const SCORE &value) {
    m_estimatedScore = value;
  }

  std::string Debug(const System &system) const;

  size_t GetNumNonTerms() const;

  //mutable void *chartState;
protected:
  SCORE m_estimatedScore;

  const AlignmentInfo *m_alignNonTerm;

  // ALNREP = alignment representation,
  // see AlignmentInfo constructors for supported representations
  template<typename ALNREP>
  void
  SetAlignNonTerm(const ALNREP &coll) {
    m_alignNonTerm = AlignmentInfoCollection::Instance().Add(coll);
  }

};


}
}