Skip to content

Commit

Permalink
get rid of weight in LM class
Browse files Browse the repository at this point in the history
  • Loading branch information
hieuhoang1972 committed Sep 15, 2010
1 parent d5710c5 commit 9aeca75
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 21 deletions.
8 changes: 8 additions & 0 deletions moses/moses.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
/* Begin PBXBuildFile section */
1E059677123FB1E900D39289 /* OnlineCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E059675123FB1E900D39289 /* OnlineCommand.cpp */; };
1E059678123FB1E900D39289 /* OnlineCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E059676123FB1E900D39289 /* OnlineCommand.h */; };
1E20EFF01241211A00D7FE95 /* BleuScoreFeature.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E20EFEE1241211A00D7FE95 /* BleuScoreFeature.cpp */; };
1E20EFF11241211A00D7FE95 /* BleuScoreFeature.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E20EFEF1241211A00D7FE95 /* BleuScoreFeature.h */; };
1E5D8E0411F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E5D8E0211F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp */; };
1E5D8E0511F25F03000F027F /* PhraseDictionaryNodeSCFG.h in Headers */ = {isa = PBXBuildFile; fileRef = 1E5D8E0311F25F03000F027F /* PhraseDictionaryNodeSCFG.h */; };
1E5D8E0811F25F2F000F027F /* PhraseDictionarySCFG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1E5D8E0611F25F2F000F027F /* PhraseDictionarySCFG.cpp */; };
Expand Down Expand Up @@ -228,6 +230,8 @@
/* Begin PBXFileReference section */
1E059675123FB1E900D39289 /* OnlineCommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = OnlineCommand.cpp; path = src/OnlineCommand.cpp; sourceTree = "<group>"; };
1E059676123FB1E900D39289 /* OnlineCommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OnlineCommand.h; path = src/OnlineCommand.h; sourceTree = "<group>"; };
1E20EFEE1241211A00D7FE95 /* BleuScoreFeature.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = BleuScoreFeature.cpp; path = src/BleuScoreFeature.cpp; sourceTree = "<group>"; };
1E20EFEF1241211A00D7FE95 /* BleuScoreFeature.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BleuScoreFeature.h; path = src/BleuScoreFeature.h; sourceTree = "<group>"; };
1E5D8E0211F25F03000F027F /* PhraseDictionaryNodeSCFG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PhraseDictionaryNodeSCFG.cpp; path = src/PhraseDictionaryNodeSCFG.cpp; sourceTree = "<group>"; };
1E5D8E0311F25F03000F027F /* PhraseDictionaryNodeSCFG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PhraseDictionaryNodeSCFG.h; path = src/PhraseDictionaryNodeSCFG.h; sourceTree = "<group>"; };
1E5D8E0611F25F2F000F027F /* PhraseDictionarySCFG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PhraseDictionarySCFG.cpp; path = src/PhraseDictionarySCFG.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -471,6 +475,8 @@
08FB7795FE84155DC02AAC07 /* Source */ = {
isa = PBXGroup;
children = (
1E20EFEE1241211A00D7FE95 /* BleuScoreFeature.cpp */,
1E20EFEF1241211A00D7FE95 /* BleuScoreFeature.h */,
1E059675123FB1E900D39289 /* OnlineCommand.cpp */,
1E059676123FB1E900D39289 /* OnlineCommand.h */,
1ED4FC5F11BDC0D2004E826A /* AlignmentInfo.cpp */,
Expand Down Expand Up @@ -837,6 +843,7 @@
1EF549BA12118A5D00C481EB /* TranslationSystem.h in Headers */,
1E7739D1123F646800B88EB7 /* FeatureVector.h in Headers */,
1E059678123FB1E900D39289 /* OnlineCommand.h in Headers */,
1E20EFF11241211A00D7FE95 /* BleuScoreFeature.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -985,6 +992,7 @@
1EF549B912118A5D00C481EB /* TranslationSystem.cpp in Sources */,
1E7739D0123F646800B88EB7 /* FeatureVector.cpp in Sources */,
1E059677123FB1E900D39289 /* OnlineCommand.cpp in Sources */,
1E20EFF01241211A00D7FE95 /* BleuScoreFeature.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
6 changes: 6 additions & 0 deletions moses/src/LanguageModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,10 @@ FFState* LanguageModel::Evaluate(
return res;
}

float LanguageModel::GetWeight() const {
size_t lmIndex = StaticData::Instance().GetScoreIndexManager().
GetBeginIndex(GetScoreBookkeepingID());
return StaticData::Instance().GetAllWeights()[lmIndex];
}

}
14 changes: 2 additions & 12 deletions moses/src/LanguageModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class Phrase;
class LanguageModel : public StatefulFeatureFunction
{
protected:
float m_weight; //! scoring weight. Shouldn't this now be superceded by ScoreProducer???
std::string m_filePath; //! for debugging purposes
size_t m_nGramOrder; //! max n-gram length contained in this LM
Word m_sentenceStartArray, m_sentenceEndArray; //! Contains factors which represents the beging and end words for this LM.
Expand Down Expand Up @@ -107,7 +106,8 @@ class LanguageModel : public StatefulFeatureFunction
{
return m_nGramOrder;
}

float GetWeight() const;

//! Contains factors which represents the beging and end words for this LM. Usually <s> and </s>
const Word &GetSentenceStartArray() const
{
Expand All @@ -120,16 +120,6 @@ class LanguageModel : public StatefulFeatureFunction

virtual std::string GetScoreProducerDescription() const = 0;

//! scoring weight. Shouldn't this now be superceded by ScoreProducer???
float GetWeight() const
{
return m_weight;
}
void SetWeight(float weight)
{
m_weight = weight;
}

std::string GetScoreProducerWeightShortName() const
{
return "lm";
Expand Down
9 changes: 0 additions & 9 deletions moses/src/StaticData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1365,15 +1365,6 @@ void StaticData::ReLoadParameter()
phraseDictionary.SetWeightTransModel(tmp_weights);
}

const LMList &languageModels = transSystem.GetLanguageModels();
LMList::const_iterator lmIter;
size_t index_WeightLM = 0;
for (lmIter = languageModels.begin(); lmIter != languageModels.end(); ++lmIter)
{
LanguageModel &lm = **lmIter;

lm.SetWeight(WeightsLM[index_WeightLM++]);
}
}

}
Expand Down

0 comments on commit 9aeca75

Please sign in to comment.