summaryrefslogtreecommitdiff
path: root/dtrain
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
committerKenneth Heafield <github@kheafield.com>2012-08-03 07:46:54 -0400
commit122f46c31102b683eaab3ad81a3a98accbc694bb (patch)
tree8d499d789b159ebed25bb23b6983813d064a6296 /dtrain
parentac664bdb0e481539cf77098a7dd0e1ec8d937ba0 (diff)
parent193d137056c3c4f73d66f8db84691d63307de894 (diff)
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'dtrain')
-rw-r--r--dtrain/dtrain.cc4
-rw-r--r--dtrain/score.cc8
2 files changed, 6 insertions, 6 deletions
diff --git a/dtrain/dtrain.cc b/dtrain/dtrain.cc
index b3e62914..b7a4bb6f 100644
--- a/dtrain/dtrain.cc
+++ b/dtrain/dtrain.cc
@@ -364,7 +364,7 @@ main(int argc, char** argv)
boost::replace_all(in, "\t", "\n");
in += "\n";
grammar_buf_out << in << DTRAIN_GRAMMAR_DELIM << " " << in_split[0] << endl;
- decoder.SetSentenceGrammarFromString(in);
+ decoder.AddSupplementalGrammarFromString(in);
src_str_buf.push_back(in_split[1]);
// decode
observer->SetRef(ref_ids);
@@ -378,7 +378,7 @@ main(int argc, char** argv)
if (boost::starts_with(rule, DTRAIN_GRAMMAR_DELIM)) break;
grammar_str += rule + "\n";
}
- decoder.SetSentenceGrammarFromString(grammar_str);
+ decoder.AddSupplementalGrammarFromString(grammar_str);
// decode
observer->SetRef(ref_ids_buf[ii]);
decoder.Decode(src_str_buf[ii], observer);
diff --git a/dtrain/score.cc b/dtrain/score.cc
index 4a7cac6e..34fc86a9 100644
--- a/dtrain/score.cc
+++ b/dtrain/score.cc
@@ -103,7 +103,7 @@ SmoothBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
i_bleu[j] += (1/((score_t)j+1)) * i_ng;
}
}
- sum += exp(i_bleu[i])/(pow(2.0, N_-i));
+ sum += exp(i_bleu[i])/pow(2.0, (double)(N_-i));
}
return brevity_penalty(hyp_len, ref_len) * sum;
}
@@ -126,7 +126,7 @@ SumBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += ((score_t)counts.clipped_[i]/counts.sum_[i])/pow(2., N_-j+1);
+ sum += ((score_t)counts.clipped_[i]/counts.sum_[i])/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;
@@ -150,7 +150,7 @@ SumExpBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += exp(((score_t)counts.clipped_[i]/counts.sum_[i]))/pow(2., N_-j+1);
+ sum += exp(((score_t)counts.clipped_[i]/counts.sum_[i]))/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;
@@ -178,7 +178,7 @@ SumWhateverBleuScorer::Score(vector<WordID>& hyp, vector<WordID>& ref,
unsigned j = 1;
for (unsigned i = 0; i < M; i++) {
if (counts.sum_[i] == 0 || counts.clipped_[i] == 0) break;
- sum += exp(v[i] * log(((score_t)counts.clipped_[i]/counts.sum_[i])))/pow(2., N_-j+1);
+ sum += exp(v[i] * log(((score_t)counts.clipped_[i]/counts.sum_[i])))/pow(2.0, (double) (N_-j+1));
j++;
}
return brevity_penalty(hyp_len, ref_len) * sum;