blob: 083afb3a324f4efacd59d8d83852e673ca4ee7ee (
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
|
// -*- c++ -*-
// written by Ulrich Germann
#pragma once
#include "moses/TranslationModel/UG/mm/ug_bitext.h"
#include "util/exception.hh"
#include "boost/format.hpp"
#include "sapt_pscore_base.h"
// DEPRECATED CODE: Word and phrase penalties are now
// added by the decoder.
namespace Moses {
namespace bitext
{
/// Word penalty
template<typename Token>
class
PScoreWP : public PhraseScorer<Token>
{
public:
PScoreWP() { this->m_num_feats = 1; }
int
init(int const i)
{
this->m_index = i;
return i + this->m_num_feats;
}
void
operator()(Bitext<Token> const& bt, PhrasePair<Token>& pp,
vector<float> * dest = NULL) const
{
if (!dest) dest = &pp.fvals;
uint32_t sid2=0,off2=0,len2=0;
parse_pid(pp.p2, sid2, off2, len2);
(*dest)[this->m_index] = len2;
}
};
/// Phrase penalty
template<typename Token>
class
PScorePP : public PhraseScorer<Token>
{
public:
PScorePP() { this->m_num_feats = 1; }
int
init(int const i)
{
this->m_index = i;
return i + this->m_num_feats;
}
void
operator()(Bitext<Token> const& bt, PhrasePair<Token>& pp,
vector<float> * dest = NULL) const
{
if (!dest) dest = &pp.fvals;
(*dest)[this->m_index] = 1;
}
};
}
}
|