Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'moses/src/LanguageModelInternal.h')
-rw-r--r--moses/src/LanguageModelInternal.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/moses/src/LanguageModelInternal.h b/moses/src/LanguageModelInternal.h
new file mode 100644
index 000000000..4302e895c
--- /dev/null
+++ b/moses/src/LanguageModelInternal.h
@@ -0,0 +1,43 @@
+
+#pragma once
+
+#include "LanguageModelSingleFactor.h"
+#include "NGramCollection.h"
+
+namespace Moses
+{
+
+/** Guaranteed cross-platform LM implementation designed to mimic LM used in regression tests
+*/
+class LanguageModelInternal : public LanguageModelSingleFactor
+{
+protected:
+ std::vector<const NGramNode*> m_lmIdLookup;
+ NGramCollection m_map;
+
+ const NGramNode* GetLmID( const Factor *factor ) const
+ {
+ size_t factorId = factor->GetId();
+ return ( factorId >= m_lmIdLookup.size()) ? NULL : m_lmIdLookup[factorId];
+ };
+
+ float GetValue(const Factor *factor0, State* finalState) const;
+ float GetValue(const Factor *factor0, const Factor *factor1, State* finalState) const;
+ float GetValue(const Factor *factor0, const Factor *factor1, const Factor *factor2, State* finalState) const;
+
+public:
+ LanguageModelInternal(bool registerScore, ScoreIndexManager &scoreIndexManager);
+ bool Load(const std::string &filePath
+ , FactorType factorType
+ , float weight
+ , size_t nGramOrder);
+ float GetValue(const std::vector<const Word*> &contextFactor
+ , State* finalState = 0
+ , unsigned int* len = 0) const;
+
+ std::string GetScoreProducerDescription() const
+ {return "LanguageModelInternal"; }
+};
+
+}
+