blob: 21f5c76a57a88b9ee50e4a3416eab49afde434fa (
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
|
#include "max_lex_source_given_target.h"
#include <cmath>
#include "../data_array.h"
#include "../translation_table.h"
MaxLexSourceGivenTarget::MaxLexSourceGivenTarget(
shared_ptr<TranslationTable> table) :
table(table) {}
double MaxLexSourceGivenTarget::Score(const FeatureContext& context) const {
vector<string> source_words = context.source_phrase.GetWords();
vector<string> target_words = context.target_phrase.GetWords();
target_words.push_back(DataArray::NULL_WORD_STR);
double score = 0;
for (string source_word: source_words) {
double max_score = 0;
for (string target_word: target_words) {
max_score = max(max_score,
table->GetSourceGivenTargetScore(source_word, target_word));
}
score += max_score > 0 ? -log10(max_score) : MAX_SCORE;
}
return score;
}
string MaxLexSourceGivenTarget::GetName() const {
return "MaxLexFgivenE";
}
|