blob: d1cf39c0089767d252cf70393eb7854e2019df97 (
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
|
#pragma once
#include <cassert>
#include <vector>
#include "Word.h"
#include "WordsRange.h"
#include "TargetPhrase.h"
namespace Moses
{
class WordConsumed;
// basically a phrase translation and the vector of words consumed to map each word
class ChartRule
{
friend std::ostream& operator<<(std::ostream&, const ChartRule&);
protected:
const Moses::TargetPhrase &m_targetPhrase;
const WordConsumed &m_lastWordConsumed;
/* map each source word in the phrase table to:
1. a word in the input sentence, if the pt word is a terminal
2. a 1+ phrase in the input sentence, if the pt word is a non-terminal
*/
std::vector<size_t> m_wordsConsumedTargetOrder;
/* size is the size of the target phrase.
Usually filled with NOT_KNOWN, unless the pos is a non-term, in which case its filled
with its index
*/
ChartRule(const ChartRule ©); // not implmenented
public:
ChartRule(const TargetPhrase &targetPhrase, const WordConsumed &lastWordConsumed)
:m_targetPhrase(targetPhrase)
,m_lastWordConsumed(lastWordConsumed)
{}
~ChartRule()
{}
const TargetPhrase &GetTargetPhrase() const
{ return m_targetPhrase; }
const WordConsumed &GetLastWordConsumed() const
{
return m_lastWordConsumed;
}
const std::vector<size_t> &GetWordsConsumedTargetOrder() const
{ return m_wordsConsumedTargetOrder; }
void CreateNonTermIndex();
bool operator<(const ChartRule &compare) const;
};
}
|