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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2014-12-22 19:00:07 +0300
committerMarcin Junczys-Dowmunt <junczys@amu.edu.pl>2014-12-22 19:00:07 +0300
commitc2b1a1e4d73f608eba1ba3751daa79375af77357 (patch)
treee68b2bb7db4cf45d76e9d41db29ea35f4ad0ecee
parente9d6576f600d563aa4825be4c1093991a074af14 (diff)
added penalty for zero-similarity beads
-rw-r--r--contrib/bleu-champ/Dynamic.hpp14
-rw-r--r--contrib/bleu-champ/Scorer.hpp9
2 files changed, 10 insertions, 13 deletions
diff --git a/contrib/bleu-champ/Dynamic.hpp b/contrib/bleu-champ/Dynamic.hpp
index e12f59773..7a2ea79a1 100644
--- a/contrib/bleu-champ/Dynamic.hpp
+++ b/contrib/bleu-champ/Dynamic.hpp
@@ -63,12 +63,12 @@ struct Search {
return m_allowedBeads;
}
- //virtual float Penalty(const Bead& bead) const {
- // // TODO: EVIL!!! Satan did this!
- // if(bead[0] == 0 || bead[1] == 0)
- // return -0.1;
- // return 0.0;
- //}
+ virtual float Penalty(const Bead& bead) const {
+ // TODO: EVIL!!! Satan did this!
+ if(bead[0] == 0 || bead[1] == 0)
+ return -0.1;
+ return 0.0;
+ }
private:
Beads& m_allowedBeads;
@@ -133,7 +133,7 @@ class Dynamic {
score = Align(i - bead[0], j - bead[1])
+ m_config.Scorer()(m_corpus1(i - bead[0], i - 1),
m_corpus2(j - bead[1], j - 1))
- ; //+ m_config.Search().Penalty(bead);
+ + m_config.Search().Penalty(bead);
if(score > bestScore) {
bestScore = score;
diff --git a/contrib/bleu-champ/Scorer.hpp b/contrib/bleu-champ/Scorer.hpp
index ca5ce970a..abf14a393 100644
--- a/contrib/bleu-champ/Scorer.hpp
+++ b/contrib/bleu-champ/Scorer.hpp
@@ -8,7 +8,7 @@ class BLEU {
template <class Sentence>
float operator()(const Sentence& c, const Sentence& r) const {
if(c.size() == 0 || r.size() == 0)
- return -0.1;
+ return 0.0;
std::vector<float> stats(MAX_NGRAM_ORDER * 3, 0);
computeBLEUSymStats(c, r, stats);
@@ -29,7 +29,7 @@ class BLEU {
smoothing = 1.0;
if(stats[3*i+1] + smoothing == 0)
- return -0.1;
+ return 0.0;
logbleu1 += log(stats[3*i] + smoothing) - log(stats[3*i+1] + smoothing);
logbleu2 += log(stats[3*i] + smoothing) - log(stats[3*i+2] + smoothing);
@@ -47,10 +47,7 @@ class BLEU {
logbleu2 += brevity2;
}
- float bleu = exp((logbleu1 + logbleu2)/2);
- if(bleu == 0)
- return -0.1;
- return bleu;
+ return exp((logbleu1 + logbleu2)/2);
}
template <class Sentence>