mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-06 08:18:02 +03:00
dynamic updating
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/mira-mtm5@3432 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
ff7ce559b7
commit
6bdcbe44f5
@ -467,13 +467,6 @@
|
||||
08FB7795FE84155DC02AAC07 /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1E7739CE123F646800B88EB7 /* FeatureVector.cpp */,
|
||||
1E7739CF123F646800B88EB7 /* FeatureVector.h */,
|
||||
1EF549B712118A5D00C481EB /* TranslationSystem.cpp */,
|
||||
1EF549B812118A5D00C481EB /* TranslationSystem.h */,
|
||||
1EF549B512118A4A00C481EB /* LanguageModelDelegate.h */,
|
||||
1EF549AF12118A0B00C481EB /* DecodeFeature.cpp */,
|
||||
1EF549B012118A0C00C481EB /* DecodeFeature.h */,
|
||||
1ED4FC5F11BDC0D2004E826A /* AlignmentInfo.cpp */,
|
||||
1ED4FC6011BDC0D2004E826A /* AlignmentInfo.h */,
|
||||
1ED4FC6111BDC0D2004E826A /* BilingualDynSuffixArray.cpp */,
|
||||
@ -487,6 +480,8 @@
|
||||
1ED4FC6911BDC0D2004E826A /* ChartRuleCollection.h */,
|
||||
1ED4FC6A11BDC0D2004E826A /* ConfusionNet.cpp */,
|
||||
1ED4FC6B11BDC0D2004E826A /* ConfusionNet.h */,
|
||||
1EF549AF12118A0B00C481EB /* DecodeFeature.cpp */,
|
||||
1EF549B012118A0C00C481EB /* DecodeFeature.h */,
|
||||
1ED4FC6C11BDC0D2004E826A /* DecodeGraph.cpp */,
|
||||
1ED4FC6D11BDC0D2004E826A /* DecodeGraph.h */,
|
||||
1ED4FC6E11BDC0D2004E826A /* DecodeStep.cpp */,
|
||||
@ -514,6 +509,8 @@
|
||||
1ED4FC8B11BDC0D2004E826A /* FactorTypeSet.h */,
|
||||
1ED4FC8C11BDC0D2004E826A /* FeatureFunction.cpp */,
|
||||
1ED4FC8D11BDC0D2004E826A /* FeatureFunction.h */,
|
||||
1E7739CE123F646800B88EB7 /* FeatureVector.cpp */,
|
||||
1E7739CF123F646800B88EB7 /* FeatureVector.h */,
|
||||
1ED4FC8E11BDC0D2004E826A /* FFState.cpp */,
|
||||
1ED4FC8F11BDC0D2004E826A /* FFState.h */,
|
||||
1ED4FC9011BDC0D2004E826A /* File.cpp */,
|
||||
@ -543,6 +540,7 @@
|
||||
1ED4FCA811BDC0D2004E826A /* InputType.h */,
|
||||
1ED4FCA911BDC0D2004E826A /* LanguageModel.cpp */,
|
||||
1ED4FCAA11BDC0D2004E826A /* LanguageModel.h */,
|
||||
1EF549B512118A4A00C481EB /* LanguageModelDelegate.h */,
|
||||
1ED4FCAB11BDC0D2004E826A /* LanguageModelFactory.cpp */,
|
||||
1ED4FCAC11BDC0D2004E826A /* LanguageModelFactory.h */,
|
||||
1ED4FCAD11BDC0D2004E826A /* LanguageModelInternal.cpp */,
|
||||
@ -652,6 +650,8 @@
|
||||
1ED4FD1B11BDC0D2004E826A /* TranslationOptionCollectionText.h */,
|
||||
1ED4FD1C11BDC0D2004E826A /* TranslationOptionList.cpp */,
|
||||
1ED4FD1D11BDC0D2004E826A /* TranslationOptionList.h */,
|
||||
1EF549B712118A5D00C481EB /* TranslationSystem.cpp */,
|
||||
1EF549B812118A5D00C481EB /* TranslationSystem.h */,
|
||||
1ED4FD1E11BDC0D2004E826A /* TreeInput.cpp */,
|
||||
1ED4FD1F11BDC0D2004E826A /* TreeInput.h */,
|
||||
1ED4FD2011BDC0D2004E826A /* TrellisPath.cpp */,
|
||||
|
@ -227,7 +227,17 @@ const PhraseDictionary* PhraseDictionaryFeature::GetDictionary() const {
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
PhraseDictionary* PhraseDictionaryFeature::GetDictionary() {
|
||||
PhraseDictionary* dict;
|
||||
if (m_useThreadSafePhraseDictionary) {
|
||||
dict = m_threadSafePhraseDictionary.get();
|
||||
} else {
|
||||
dict = m_threadUnsafePhraseDictionary.get();
|
||||
}
|
||||
assert(dict);
|
||||
return dict;
|
||||
}
|
||||
|
||||
|
||||
PhraseDictionaryFeature::~PhraseDictionaryFeature()
|
||||
{}
|
||||
|
@ -124,6 +124,7 @@ class PhraseDictionaryFeature : public DecodeFeature
|
||||
|
||||
//Get the dictionary. Be sure to initialise it first.
|
||||
const PhraseDictionary* GetDictionary() const;
|
||||
PhraseDictionary* GetDictionary();
|
||||
|
||||
private:
|
||||
/** Load the appropriate phrase table */
|
||||
|
@ -1260,8 +1260,10 @@ void StaticData::ReLoadParameter()
|
||||
}
|
||||
|
||||
//loop over all ScoreProducer to update weights
|
||||
const TranslationSystem &transSystem = GetTranslationSystem(TranslationSystem::DEFAULT);
|
||||
|
||||
std::vector<const ScoreProducer*>::const_iterator iterSP;
|
||||
for (iterSP = GetScoreIndexManager().GetFeatureFunctions().begin() ; iterSP != GetScoreIndexManager().GetFeatureFunctions().end() ; ++iterSP)
|
||||
for (iterSP = transSystem.GetFeatureFunctions().begin() ; iterSP != transSystem.GetFeatureFunctions().end() ; ++iterSP)
|
||||
{
|
||||
std::string paramShortName = (*iterSP)->GetScoreProducerWeightShortName();
|
||||
vector<float> Weights = Scan<float>(m_parameter->GetParamShortName(paramShortName));
|
||||
@ -1279,14 +1281,8 @@ void StaticData::ReLoadParameter()
|
||||
// std::cerr << Weights << std::endl;
|
||||
}
|
||||
|
||||
m_weightWordPenalty = Scan<float>(m_parameter->GetParamShortName("w")[0]);
|
||||
m_weightUnknownWord = Scan<float>(m_parameter->GetParamShortName("u")[0]);
|
||||
m_weightDistortion = Scan<float>(m_parameter->GetParamShortName("d")[0]);
|
||||
|
||||
|
||||
// std::cerr << "There are " << m_phraseDictionary.size() << " m_phraseDictionaryfeatures" << std::endl;
|
||||
|
||||
const float weightWP = Scan<float>(m_parameter->GetParamShortName("w"))[0];
|
||||
const vector<float> WeightsTM = Scan<float>(m_parameter->GetParamShortName("tm"));
|
||||
// std::cerr << "WeightsTM: " << WeightsTM << std::endl;
|
||||
|
||||
@ -1294,7 +1290,7 @@ void StaticData::ReLoadParameter()
|
||||
// std::cerr << "WeightsLM: " << WeightsLM << std::endl;
|
||||
|
||||
size_t index_WeightTM = 0;
|
||||
for(size_t i=0;i<m_phraseDictionary.size();++i)
|
||||
for(size_t i=0;i<transSystem.GetPhraseDictionaries().size();++i)
|
||||
{
|
||||
PhraseDictionaryFeature &phraseDictionaryFeature = *m_phraseDictionary[i];
|
||||
PhraseDictionary &phraseDictionary = *phraseDictionaryFeature.GetDictionary();
|
||||
@ -1311,7 +1307,7 @@ void StaticData::ReLoadParameter()
|
||||
phraseDictionary.SetWeightTransModel(tmp_weights);
|
||||
}
|
||||
|
||||
const LMList &languageModels = GetAllLM();
|
||||
const LMList &languageModels = transSystem.GetLanguageModels();
|
||||
LMList::const_iterator lmIter;
|
||||
size_t index_WeightLM = 0;
|
||||
for (lmIter = languageModels.begin(); lmIter != languageModels.end(); ++lmIter)
|
||||
|
@ -77,6 +77,8 @@ namespace Moses {
|
||||
|
||||
|
||||
void TranslationSystem::AddFeatureFunction(const FeatureFunction* ff) {
|
||||
m_producers.push_back(ff);
|
||||
|
||||
if (ff->IsStateless()) {
|
||||
const StatelessFeatureFunction* statelessFF = static_cast<const StatelessFeatureFunction*>(ff);
|
||||
if (!statelessFF->ComputeValueInTranslationOption()) {
|
||||
|
@ -89,11 +89,10 @@ class TranslationSystem {
|
||||
void InitializeBeforeSentenceProcessing(const InputType& source) const;
|
||||
void CleanUpAfterSentenceProcessing() const;
|
||||
|
||||
|
||||
|
||||
static const std::string DEFAULT;
|
||||
const std::vector<const ScoreProducer*>& GetFeatureFunctions() const { return m_producers; }
|
||||
|
||||
|
||||
static const std::string DEFAULT;
|
||||
|
||||
|
||||
private:
|
||||
@ -114,6 +113,9 @@ class TranslationSystem {
|
||||
const WordPenaltyProducer* m_wpProducer;
|
||||
const UnknownWordPenaltyProducer* m_unknownWpProducer;
|
||||
const DistortionScoreProducer* m_distortionScoreProducer;
|
||||
|
||||
std::vector<const ScoreProducer*> m_producers; /**< all the score producers in this run */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user