diff options
author | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2007-11-13 19:18:42 +0300 |
---|---|---|
committer | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2007-11-13 19:18:42 +0300 |
commit | e2d8dfb420a1a1aa9befb85754402e79ce5afd10 (patch) | |
tree | 74208ba1283f813c89e202415dba73f7e3b0687f /moses | |
parent | 2672b8cb34c8f990fd7568adbd8570af6a03c997 (diff) |
bug fix for multiple phrase tables
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1512 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses')
-rw-r--r-- | moses/src/DecodeStep.h | 1 | ||||
-rw-r--r-- | moses/src/DecodeStepTranslation.h | 1 | ||||
-rwxr-xr-x | moses/src/Manager.cpp | 2 | ||||
-rwxr-xr-x | moses/src/StaticData.cpp | 5 | ||||
-rwxr-xr-x | moses/src/StaticData.h | 4 | ||||
-rw-r--r-- | moses/src/TranslationOptionCollection.cpp | 8 | ||||
-rwxr-xr-x | moses/src/TranslationOptionCollection.h | 4 |
7 files changed, 14 insertions, 11 deletions
diff --git a/moses/src/DecodeStep.h b/moses/src/DecodeStep.h index c85308913..146841ecb 100644 --- a/moses/src/DecodeStep.h +++ b/moses/src/DecodeStep.h @@ -49,6 +49,7 @@ protected: std::vector<FactorType> m_newOutputFactors; /** list of the factors that are new in this step, may be empty*/ public: + DecodeStep(); // not implemented DecodeStep(Dictionary *ptr, const DecodeStep* prevDecodeStep); virtual ~DecodeStep(); diff --git a/moses/src/DecodeStepTranslation.h b/moses/src/DecodeStepTranslation.h index 1acce868c..2a8f47e61 100644 --- a/moses/src/DecodeStepTranslation.h +++ b/moses/src/DecodeStepTranslation.h @@ -29,6 +29,7 @@ class TargetPhrase; class DecodeStepTranslation : public DecodeStep { public: + DecodeStepTranslation(); // not implemented DecodeStepTranslation(PhraseDictionary* dict, const DecodeStep* prev); /** returns phrase table (dictionary) for translation step */ diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp index 42ada55bb..9ec7baa62 100755 --- a/moses/src/Manager.cpp +++ b/moses/src/Manager.cpp @@ -84,7 +84,7 @@ void Manager::ProcessSentence() { const StaticData &staticData = StaticData::Instance(); staticData.ResetSentenceStats(m_source); - const vector <DecodeGraph> + const vector <DecodeGraph*> &decodeStepVL = staticData.GetDecodeStepVL(); // create list of all possible translations diff --git a/moses/src/StaticData.cpp b/moses/src/StaticData.cpp index 8f52ab366..54f342c2d 100755 --- a/moses/src/StaticData.cpp +++ b/moses/src/StaticData.cpp @@ -287,6 +287,7 @@ StaticData::~StaticData() RemoveAllInColl(m_phraseDictionary); RemoveAllInColl(m_generationDictionary); RemoveAllInColl(m_languageModel); + RemoveAllInColl(m_decodeStepVL); // delete trans opt map<Phrase, std::vector<TranslationOption*> >::iterator iterCache; @@ -773,9 +774,9 @@ bool StaticData::LoadMapping() assert(decodeStep); if (m_decodeStepVL.size() < vectorList + 1) { - m_decodeStepVL.push_back(DecodeGraph()); + m_decodeStepVL.push_back(new DecodeGraph()); } - m_decodeStepVL[vectorList].Add(decodeStep); + m_decodeStepVL[vectorList]->Add(decodeStep); prev = decodeStep; previousVectorList = vectorList; } diff --git a/moses/src/StaticData.h b/moses/src/StaticData.h index 9486ac07b..79d982ea5 100755 --- a/moses/src/StaticData.h +++ b/moses/src/StaticData.h @@ -52,7 +52,7 @@ private: protected: std::vector<PhraseDictionary*> m_phraseDictionary; std::vector<GenerationDictionary*> m_generationDictionary; - std::vector <DecodeGraph> m_decodeStepVL; + std::vector <DecodeGraph*> m_decodeStepVL; Parameter *m_parameter; std::vector<FactorType> m_inputFactorOrder, m_outputFactorOrder; LMList m_languageModel; @@ -190,7 +190,7 @@ public: return m_outputFactorOrder; } - const std::vector<DecodeGraph> &GetDecodeStepVL() const + const std::vector<DecodeGraph*> &GetDecodeStepVL() const { return m_decodeStepVL; } diff --git a/moses/src/TranslationOptionCollection.cpp b/moses/src/TranslationOptionCollection.cpp index 54ad0a5a3..10fecb606 100644 --- a/moses/src/TranslationOptionCollection.cpp +++ b/moses/src/TranslationOptionCollection.cpp @@ -141,13 +141,13 @@ void TranslationOptionCollection::Prune() * \param factorCollection input sentence with all factors */ -void TranslationOptionCollection::ProcessUnknownWord(const std::vector <DecodeGraph> &decodeStepVL) +void TranslationOptionCollection::ProcessUnknownWord(const std::vector <DecodeGraph*> &decodeStepVL) { size_t size = m_source.GetSize(); // try to translation for coverage with no trans by expanding table limit for (size_t startVL = 0 ; startVL < decodeStepVL.size() ; startVL++) { - const DecodeGraph &decodeStepList = decodeStepVL[startVL]; + const DecodeGraph &decodeStepList = *decodeStepVL[startVL]; for (size_t pos = 0 ; pos < size ; ++pos) { TranslationOptionList &fullList = GetTranslationOptionList(pos, pos); @@ -331,7 +331,7 @@ void TranslationOptionCollection::CalcFutureScore() * \param decodeStepList list of decoding steps * \param factorCollection input sentence with all factors */ -void TranslationOptionCollection::CreateTranslationOptions(const vector <DecodeGraph> &decodeStepVL) +void TranslationOptionCollection::CreateTranslationOptions(const vector <DecodeGraph*> &decodeStepVL) { // loop over all substrings of the source sentence, look them up // in the phraseDictionary (which is the- possibly filtered-- phrase @@ -339,7 +339,7 @@ void TranslationOptionCollection::CreateTranslationOptions(const vector <DecodeG // for all phrases for (size_t startVL = 0 ; startVL < decodeStepVL.size() ; startVL++) { - const DecodeGraph &decodeStepList = decodeStepVL[startVL]; + const DecodeGraph &decodeStepList = *decodeStepVL[startVL]; for (size_t startPos = 0 ; startPos < m_source.GetSize() ; startPos++) { size_t maxSize = m_source.GetSize() - startPos; diff --git a/moses/src/TranslationOptionCollection.h b/moses/src/TranslationOptionCollection.h index 403ebd46b..a047bbee4 100755 --- a/moses/src/TranslationOptionCollection.h +++ b/moses/src/TranslationOptionCollection.h @@ -70,7 +70,7 @@ protected: void CalcFutureScore(); //! Force a creation of a translation option where there are none for a particular source position. - void ProcessUnknownWord(const std::vector <DecodeGraph> &decodeStepVL); + void ProcessUnknownWord(const std::vector <DecodeGraph*> &decodeStepVL); //! special handling of ONE unknown words. virtual void ProcessOneUnknownWord(const Word &sourceWord , size_t sourcePos, size_t length = 1); @@ -104,7 +104,7 @@ public: size_t GetSize() const { return m_source.GetSize(); }; //! Create all possible translations from the phrase tables - virtual void CreateTranslationOptions(const std::vector <DecodeGraph> &decodeStepVL); + virtual void CreateTranslationOptions(const std::vector <DecodeGraph*> &decodeStepVL); //! Create translation options that exactly cover a specific input span. virtual void CreateTranslationOptionsForRange(const DecodeGraph &decodeStepList , size_t startPosition |