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

sapt_pscore_provenance.h « UG « TranslationModel « moses - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c33b98fe798fc92c9210562b3b8e7ff3bac78e14 (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>

using namespace std;
namespace Moses {
  namespace bitext {
    
    // asymptotic provenance feature n/(n+x)
    template<typename Token>
    class
    PScoreProvenance : public SingleRealValuedParameterPhraseScorerFamily<Token>
    {
    public:

      PScoreProvenance(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, 
		 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 bitext
} // namespace Moses