diff options
author | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-31 03:11:38 +0400 |
---|---|---|
committer | Hieu Hoang <hieu@hoang.co.uk> | 2013-05-31 03:11:38 +0400 |
commit | bc0fdfbd79efe575bc6c96588068c7263f027a70 (patch) | |
tree | 5970b1b455368fc4e117ead8936d1c3bb67801c5 | |
parent | 65d2d68bc5aa405e74986c3c1a7b3bcf845ee231 (diff) |
delete LM:Useable(). Superseded by IsUseable() for all feature functions
-rw-r--r-- | moses/LM/Base.cpp | 41 | ||||
-rw-r--r-- | moses/LM/Base.h | 6 | ||||
-rw-r--r-- | moses/LM/Ken.cpp | 4 | ||||
-rw-r--r-- | moses/LM/LDHT.cpp | 6 | ||||
-rw-r--r-- | moses/LM/MultiFactor.cpp | 14 | ||||
-rw-r--r-- | moses/LM/MultiFactor.h | 1 | ||||
-rw-r--r-- | moses/LM/SingleFactor.h | 4 |
7 files changed, 19 insertions, 57 deletions
diff --git a/moses/LM/Base.cpp b/moses/LM/Base.cpp index 37dc704de..6c6cad1dd 100644 --- a/moses/LM/Base.cpp +++ b/moses/LM/Base.cpp @@ -69,28 +69,25 @@ void LanguageModel::Evaluate(const Phrase &source , ScoreComponentCollection &scoreBreakdown , ScoreComponentCollection &estimatedFutureScore) const { - if (Useable(targetPhrase)) { - // contains factors used by this LM - float fullScore, nGramScore; - size_t oovCount; - - CalcScore(targetPhrase, fullScore, nGramScore, oovCount); - float estimateScore = fullScore - nGramScore; - - if (StaticData::Instance().GetLMEnableOOVFeature()) { - vector<float> scores(2), estimateScores(2); - scores[0] = nGramScore; - scores[1] = oovCount; - scoreBreakdown.Assign(this, scores); - - estimateScores[0] = estimateScore; - estimateScores[1] = 0; - estimatedFutureScore.Assign(this, estimateScores); - } else { - scoreBreakdown.Assign(this, nGramScore); - estimatedFutureScore.Assign(this, estimateScore); - } - + // contains factors used by this LM + float fullScore, nGramScore; + size_t oovCount; + + CalcScore(targetPhrase, fullScore, nGramScore, oovCount); + float estimateScore = fullScore - nGramScore; + + if (StaticData::Instance().GetLMEnableOOVFeature()) { + vector<float> scores(2), estimateScores(2); + scores[0] = nGramScore; + scores[1] = oovCount; + scoreBreakdown.Assign(this, scores); + + estimateScores[0] = estimateScore; + estimateScores[1] = 0; + estimatedFutureScore.Assign(this, estimateScores); + } else { + scoreBreakdown.Assign(this, nGramScore); + estimatedFutureScore.Assign(this, estimateScore); } } diff --git a/moses/LM/Base.h b/moses/LM/Base.h index 1f976ee53..bb054344d 100644 --- a/moses/LM/Base.h +++ b/moses/LM/Base.h @@ -64,15 +64,9 @@ public: virtual const FFState* EmptyHypothesisState(const InputType &input) const = 0; - /* whether this LM can be used on a particular phrase. - * Should return false if phrase size = 0 or factor types required don't exists - */ - virtual bool Useable(const Phrase &phrase) const = 0; - /* calc total unweighted LM score of this phrase and return score via arguments. * Return scores should always be in natural log, regardless of representation with LM implementation. * Uses GetValue() of inherited class. - * Useable() should be called beforehand on the phrase * \param fullScore scores of all unigram, bigram... of contiguous n-gram of the phrase * \param ngramScore score of only n-gram of order m_nGramOrder * \param oovCount number of LM OOVs diff --git a/moses/LM/Ken.cpp b/moses/LM/Ken.cpp index c91d2a7a2..951606d5b 100644 --- a/moses/LM/Ken.cpp +++ b/moses/LM/Ken.cpp @@ -68,10 +68,6 @@ template <class Model> class LanguageModelKen : public LanguageModel public: LanguageModelKen(const std::string &description, const std::string &line, const std::string &file, FactorType factorType, bool lazy); - bool Useable(const Phrase &phrase) const { - return (phrase.GetSize()>0 && phrase.GetFactor(0, m_factorType) != NULL); - } - const FFState *EmptyHypothesisState(const InputType &/*input*/) const { KenLMState *ret = new KenLMState(); ret->state = m_ngram->BeginSentenceState(); diff --git a/moses/LM/LDHT.cpp b/moses/LM/LDHT.cpp index 1b4e70661..a04c33fdf 100644 --- a/moses/LM/LDHT.cpp +++ b/moses/LM/LDHT.cpp @@ -78,7 +78,6 @@ public: virtual void InitializeForInput(InputType const& source); virtual void CleanUpAfterSentenceProcessing(const InputType &source); virtual const FFState* EmptyHypothesisState(const InputType& input) const; - virtual bool Useable(const Phrase& phrase) const; virtual void CalcScore(const Phrase& phrase, float& fullScore, float& ngramScore, @@ -214,11 +213,6 @@ const FFState* LanguageModelLDHT::EmptyHypothesisState( return NULL; } -bool LanguageModelLDHT::Useable(const Phrase& phrase) const -{ - return (phrase.GetSize() > 0 && phrase.GetFactor(0, m_factorType) != NULL); -} - void LanguageModelLDHT::CalcScore(const Phrase& phrase, float& fullScore, float& ngramScore, diff --git a/moses/LM/MultiFactor.cpp b/moses/LM/MultiFactor.cpp index 03082240d..c7db718b3 100644 --- a/moses/LM/MultiFactor.cpp +++ b/moses/LM/MultiFactor.cpp @@ -24,20 +24,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA namespace Moses { -bool LanguageModelMultiFactor::Useable(const Phrase &phrase) const -{ - if (phrase.GetSize()==0) - return false; - - // whether phrase contains all factors in this LM - const Word &word = phrase.GetWord(0); - for (size_t currFactor = 0 ; currFactor < MAX_NUM_FACTORS ; ++currFactor) { - if (m_factorTypes[currFactor] && word[currFactor] == NULL) - return false; - } - return true; - -} } diff --git a/moses/LM/MultiFactor.h b/moses/LM/MultiFactor.h index 21a9d493b..1edd3920c 100644 --- a/moses/LM/MultiFactor.h +++ b/moses/LM/MultiFactor.h @@ -50,7 +50,6 @@ public: , const std::vector<FactorType> &factorTypes , size_t nGramOrder) = 0; - bool Useable(const Phrase &phrase) const; }; } diff --git a/moses/LM/SingleFactor.h b/moses/LM/SingleFactor.h index 15e4ea834..9c6d39fc9 100644 --- a/moses/LM/SingleFactor.h +++ b/moses/LM/SingleFactor.h @@ -53,10 +53,6 @@ public: bool IsUseable(const FactorMask &mask) const; - bool Useable(const Phrase &phrase) const { - return (phrase.GetSize()>0 && phrase.GetFactor(0, m_factorType) != NULL); - } - const Factor *GetSentenceStart() const { return m_sentenceStart; } |