blob: 4204a1314c95d14462a6e31415f47597c701447e (
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
|
// -*- c++ -*-
// Phrase scorer that rewards the number of phrase pair occurrences in a bitext
// with the asymptotic function j/(j+x) where x > 0 is a function
// parameter that determines the steepness of the rewards curve
// written by Ulrich Germann
#include "sapt_pscore_base.h"
#include <boost/dynamic_bitset.hpp>
namespace sapt {
// asymptotic provenance feature n/(n+x)
template<typename Token>
class
PScoreProvenance : public SingleRealValuedParameterPhraseScorerFamily<Token>
{
public:
virtual ~PScoreProvenance() {}
PScoreProvenance(std::string const& spec)
{
this->m_tag = "prov";
this->init(spec);
}
bool
isLogVal(int i) const { return false; }
void
operator()(Bitext<Token> const& bt,
PhrasePair<Token>& pp,
ttasksptr const& ttask,
std::vector<float> * dest = NULL) const
{
if (!dest) dest = &pp.fvals;
size_t i = this->m_index;
BOOST_FOREACH(float const x, this->m_x)
(*dest).at(i++) = pp.joint/(x + pp.joint);
}
bool
allowPooling() const
{ return false; }
};
} // namespace sapt
|