This commit is contained in:
Hieu Hoang 2013-05-01 11:50:29 +01:00
commit 3ed17bbedd
3 changed files with 25 additions and 14 deletions

View File

@ -42,6 +42,7 @@ bool PhraseDictionaryMultiModel::Load(const std::vector<FactorType> &input
, const vector<float> &weight
, size_t tableLimit
, size_t numInputScores
, bool isThreadSafe
, const LMList &languageModels
, float weightWP)
{
@ -93,6 +94,7 @@ bool PhraseDictionaryMultiModel::Load(const std::vector<FactorType> &input
pdm->Load( input, output, file, m_weight, m_componentTableLimit, languageModels, m_weightWP);
m_pd.push_back(pdm);
} else if (implementation == Binary) {
UTIL_THROW_IF(isThreadSafe, util::Exception, "Binarised phrase table is not thread-safe - use phrase table type " << MultiModelThreadUnsafe << " for a thread-unsafe multimodel table");
PhraseDictionaryTreeAdaptor* pdta = new PhraseDictionaryTreeAdaptor(m_numScoreComponent, numInputScores , m_feature_load);
pdta->Load(input, output, file, m_weight, m_componentTableLimit, languageModels, m_weightWP);
m_pd.push_back(pdta);

View File

@ -528,11 +528,13 @@ sigtest-filter-ttable
out: sigtest-filter-phrase-translation-table
default-name: model/phrase-table-sigtest-filter
pass-unless: sigtest-filter
ignore-if: TRAINING:config
sigtest-filter-reordering
in: reordering-table sigtest-filter-suffix-array
out: sigtest-filter-reordering-table
default-name: model/reordering-table-sigtest-filter
pass-unless: sigtest-filter
ignore-if: TRAINING:config
ignore-unless: lexicalized-reordering
build-generation
in: corpus-mml-postfilter=OR=corpus-mml-prefilter=OR=corpus

View File

@ -697,23 +697,30 @@ while (1) {
$uninterpolated_config= $___CONFIG unless $uninterpolated_config;
# Interpolation
my $interpolated_phrase_table = "naive ";
$interpolated_phrase_table .= join(" ", @_PROMIX_TABLES_BIN);
# convert from table,feature ordering to feature,table ordering
my @transposed_weights;
for my $feature (0..($num_mixed_phrase_features-1)) {
my @table_weights;
for my $table (0..(scalar(@__PROMIX_TABLES)-1)) {
push @table_weights, $promix_weights[$table * $num_mixed_phrase_features + $feature];
}
push @transposed_weights, join ",", @table_weights;
my $interpolated_phrase_table = "interpolate";
for my $itable (@_PROMIX_TABLES_BIN) {
$interpolated_phrase_table .= " 1:$itable";
}
$interpolated_phrase_table .= " ";
$interpolated_phrase_table .= join(";",@transposed_weights);
# Create an ini file for the interpolated phrase table
$interpolated_config ="moses.interpolated.ini";
substitute_ttable($uninterpolated_config, $interpolated_config, $interpolated_phrase_table, "13");
substitute_ttable($uninterpolated_config, $interpolated_config, $interpolated_phrase_table, "97");
# Append the multimodel weights
open(ITABLE,">>$interpolated_config") || die "Failed to append weights to $interpolated_config";
print ITABLE "\n";
print ITABLE "[weight-t-multimodel]\n";
#for my $feature (0..($num_mixed_phrase_features-1)) {
# for my $table (0..(scalar(@__PROMIX_TABLES)-1)) {
# print ITABLE $promix_weights[$table * $num_mixed_phrase_features + $feature];
# print ITABLE "\n";
# }
#}
for my $iweight (@promix_weights) {
print ITABLE $iweight . "\n";
}
close ITABLE;
# the decoder should now use the interpolated model
$___CONFIG = "$interpolated_config";