mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
delete ability to specify multiple translation systems
This commit is contained in:
parent
4f0d3c2032
commit
b48a906785
@ -589,54 +589,32 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
}
|
||||
}
|
||||
|
||||
//configure the translation systems with these tables
|
||||
vector<string> tsConfig = m_parameter->GetParam("translation-systems");
|
||||
if (!tsConfig.size()) {
|
||||
//use all models in default system.
|
||||
tsConfig.push_back(TranslationSystem::DEFAULT + " R * D * L * G *");
|
||||
}
|
||||
|
||||
TranslationSystem* tmpTS;
|
||||
for (size_t i = 0; i < tsConfig.size(); ++i) {
|
||||
vector<string> config = Tokenize(tsConfig[i]);
|
||||
if (config.size() % 2 != 1) {
|
||||
UserMessage::Add(string("Incorrect number of fields in Translation System config. Should be an odd number"));
|
||||
}
|
||||
m_translationSystems.insert(pair<string, TranslationSystem>(config[0],
|
||||
TranslationSystem(config[0],m_wpProducer,m_unknownWordPenaltyProducer,m_distortionScoreProducer)));
|
||||
tmpTS = &(m_translationSystems.find(config[0])->second);
|
||||
for (size_t j = 1; j < config.size(); j += 2) {
|
||||
const string& id = config[j];
|
||||
const string& tables = config[j+1];
|
||||
// rip out trans system
|
||||
vector<string> config = Tokenize(TranslationSystem::DEFAULT + " R * D * L * G *");
|
||||
set<size_t> tableIds;
|
||||
if (tables != "*") {
|
||||
//selected tables
|
||||
vector<string> tableIdStrings = Tokenize(tables,",");
|
||||
vector<size_t> tableIdList;
|
||||
Scan<size_t>(tableIdList, tableIdStrings);
|
||||
copy(tableIdList.begin(), tableIdList.end(), inserter(tableIds,tableIds.end()));
|
||||
}
|
||||
if (id == "D") {
|
||||
for (size_t k = 0; k < m_decodeGraphs.size(); ++k) {
|
||||
if (!tableIds.size() || tableIds.find(k) != tableIds.end()) {
|
||||
VERBOSE(2,"Adding decoder graph " << k << " to translation system " << config[0] << endl);
|
||||
m_translationSystems.find(config[0])->second.AddDecodeGraph(m_decodeGraphs[k],m_decodeGraphBackoff[k]);
|
||||
}
|
||||
}
|
||||
} else if (id == "R") {
|
||||
|
||||
TranslationSystem transSys(config[0],
|
||||
m_wpProducer,
|
||||
m_unknownWordPenaltyProducer,
|
||||
m_distortionScoreProducer
|
||||
);
|
||||
m_translationSystems.insert(pair<string, TranslationSystem>(config[0], transSys));
|
||||
|
||||
|
||||
for (size_t k = 0; k < m_reorderModels.size(); ++k) {
|
||||
if (!tableIds.size() || tableIds.find(k) != tableIds.end()) {
|
||||
AddFeatureFunction(m_reorderModels[k]);
|
||||
VERBOSE(2,"Adding reorder table " << k << " to translation system " << config[0] << endl);
|
||||
}
|
||||
}
|
||||
} else if (id == "G") {
|
||||
for (size_t k = 0; k < m_globalLexicalModels.size(); ++k) {
|
||||
|
||||
for (size_t k = 0; k < m_decodeGraphs.size(); ++k) {
|
||||
if (!tableIds.size() || tableIds.find(k) != tableIds.end()) {
|
||||
AddFeatureFunction(m_globalLexicalModels[k]);
|
||||
VERBOSE(2,"Adding decoder graph " << k << " to translation system " << config[0] << endl);
|
||||
m_translationSystems.find(config[0])->second.AddDecodeGraph(m_decodeGraphs[k],m_decodeGraphBackoff[k]);
|
||||
}
|
||||
}
|
||||
} else if (id == "L") {
|
||||
|
||||
size_t lmid = 0;
|
||||
for (LMList::const_iterator k = m_languageModel.begin(); k != m_languageModel.end(); ++k, ++lmid) {
|
||||
if (!tableIds.size() || tableIds.find(lmid) != tableIds.end()) {
|
||||
@ -644,14 +622,17 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
VERBOSE(2,"Adding language model " << lmid << " to translation system " << config[0] << endl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
UserMessage::Add(string("Incorrect translation system identifier: ") + id);
|
||||
return false;
|
||||
|
||||
for (size_t k = 0; k < m_globalLexicalModels.size(); ++k) {
|
||||
if (!tableIds.size() || tableIds.find(k) != tableIds.end()) {
|
||||
AddFeatureFunction(m_globalLexicalModels[k]);
|
||||
}
|
||||
}
|
||||
|
||||
//Instigate dictionary loading
|
||||
m_translationSystems.find(config[0])->second.ConfigDictionaries();
|
||||
|
||||
|
||||
//Add any other features here.
|
||||
if (m_bleuScoreFeature) {
|
||||
AddFeatureFunction(m_bleuScoreFeature);
|
||||
@ -697,7 +678,6 @@ bool StaticData::LoadData(Parameter *parameter)
|
||||
for (size_t i=0; i < m_globalLexicalModelsUnlimited.size(); ++i)
|
||||
AddFeatureFunction(m_globalLexicalModelsUnlimited[i]);
|
||||
}
|
||||
}
|
||||
|
||||
//Load extra feature weights
|
||||
//NB: These are common to all translation systems (at the moment!)
|
||||
|
Loading…
Reference in New Issue
Block a user