diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-04-30 20:27:35 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-04-30 20:27:35 +0400 |
commit | 26a4aa8d18a1d285038ecdda38deff400b107cd3 (patch) | |
tree | b69d0d0c774181fc418b0f98a0fb378297573e92 | |
parent | 75669a82c45bc780f8f57e3328b0cc3f1d1fe07e (diff) |
enable sparse feature in phrase table
-rw-r--r-- | moses/ScoreComponentCollection.cpp | 1 | ||||
-rw-r--r-- | moses/TargetPhrase.cpp | 5 | ||||
-rw-r--r-- | moses/TargetPhrase.h | 2 | ||||
-rw-r--r-- | moses/TranslationModel/RuleTable/LoaderStandard.cpp | 13 |
4 files changed, 14 insertions, 7 deletions
diff --git a/moses/ScoreComponentCollection.cpp b/moses/ScoreComponentCollection.cpp index eb70d526c..d82377c45 100644 --- a/moses/ScoreComponentCollection.cpp +++ b/moses/ScoreComponentCollection.cpp @@ -185,7 +185,6 @@ void ScoreComponentCollection::Save(const string& filename) const { } void ScoreComponentCollection::Assign(const FeatureFunction* sp, const string line) { - CHECK(sp->GetNumScoreComponents() == FeatureFunction::unlimited); istringstream istr(line); while(istr) { string namestring; diff --git a/moses/TargetPhrase.cpp b/moses/TargetPhrase.cpp index ed311239e..b62217ae7 100644 --- a/moses/TargetPhrase.cpp +++ b/moses/TargetPhrase.cpp @@ -298,6 +298,11 @@ void TargetPhrase::SetAlignNonTerm(const AlignmentInfo::CollType &coll) m_alignNonTerm = alignmentInfo; } +void TargetPhrase::SetSparseScore(const FeatureFunction* translationScoreProducer, const StringPiece &sparseString) +{ + m_scoreBreakdown.Assign(translationScoreProducer, sparseString.as_string()); +} + TO_STRING_BODY(TargetPhrase); std::ostream& operator<<(std::ostream& os, const TargetPhrase& tp) diff --git a/moses/TargetPhrase.h b/moses/TargetPhrase.h index 40b0ca17e..d68279a79 100644 --- a/moses/TargetPhrase.h +++ b/moses/TargetPhrase.h @@ -92,6 +92,8 @@ public: ,const LMList &languageModels ,const WordPenaltyProducer* wpProducer); + void SetSparseScore(const FeatureFunction* translationScoreProducer, const StringPiece &sparseString); + // used by for unknown word proc in chart decoding void SetScore(const FeatureFunction* producer, const Scores &scoreVector); diff --git a/moses/TranslationModel/RuleTable/LoaderStandard.cpp b/moses/TranslationModel/RuleTable/LoaderStandard.cpp index b959c933d..dfa10236f 100644 --- a/moses/TranslationModel/RuleTable/LoaderStandard.cpp +++ b/moses/TranslationModel/RuleTable/LoaderStandard.cpp @@ -197,12 +197,8 @@ bool RuleTableLoaderStandard::Load(FormatType format alignString = temp; } - // Allow but ignore rule count. - if (++pipes && ++pipes) { - stringstream strme; - strme << "Syntax error at " << ruleTable.GetFilePath() << ":" << count; - UserMessage::Add(strme.str()); - abort(); + if (++pipes) { + StringPiece str(*pipes); //counts } bool isLHSEmpty = (sourcePhraseString.find_first_not_of(" \t", 0) == string::npos); @@ -245,6 +241,11 @@ bool RuleTableLoaderStandard::Load(FormatType format //targetPhrase->SetDebugOutput(string("New Format pt ") + line); + if (++pipes) { + StringPiece sparseString(*pipes); + targetPhrase->SetSparseScore(&ruleTable, sparseString); + } + targetPhrase->SetScoreChart(&ruleTable, scoreVector, weight, languageModels,wpProducer); TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, targetPhrase->GetSourcePhrase(), *targetPhrase, sourceLHS); |