00001 #include "moses/LM/BilingualLM.h"
00002 #include <boost/unordered_map.hpp>
00003 #include <utility>
00004 #include <fstream>
00005
00006 namespace nplm
00007 {
00008 class neuralLM;
00009 }
00010
00011 namespace Moses
00012 {
00013
00014 class BilingualLM_NPLM : public BilingualLM
00015 {
00016 public:
00017 BilingualLM_NPLM(const std::string &line);
00018
00019 private:
00020 float Score(std::vector<int>& source_words, std::vector<int>& target_words) const;
00021
00022 int getNeuralLMId(const Word& word, bool is_source_word) const;
00023
00024 void initSharedPointer() const;
00025
00026 void loadModel();
00027
00028 void SetParameter(const std::string& key, const std::string& value);
00029
00030 const Word& getNullWord() const;
00031
00032 nplm::neuralLM *m_neuralLM_shared;
00033 mutable boost::thread_specific_ptr<nplm::neuralLM> m_neuralLM;
00034
00035 mutable boost::unordered_map<const Factor*, int> target_neuralLMids;
00036 mutable boost::unordered_map<const Factor*, int> source_neuralLMids;
00037
00038
00039 std::string NULL_string;
00040 bool NULL_overwrite;
00041 Word NULL_word;
00042
00043 std::string source_vocab_path;
00044 std::string target_vocab_path;
00045 bool premultiply;
00046 bool factored;
00047 int neuralLM_cache;
00048 int source_unknown_word_id;
00049 int target_unknown_word_id;
00050 };
00051
00052 }