00001 #pragma once 00002 00003 #include <vector> 00004 00005 #include "lbl/model.h" 00006 #include "lbl/query_cache.h" 00007 00008 #include "moses/LM/BilingualLM.h" 00009 #include "moses/LM/oxlm/OxLMParallelMapper.h" 00010 00011 namespace Moses 00012 { 00013 00014 class SourceOxLM : public BilingualLM 00015 { 00016 public: 00017 SourceOxLM(const std::string &line); 00018 00019 ~SourceOxLM(); 00020 00021 private: 00022 virtual float Score( 00023 std::vector<int>& source_words, 00024 std::vector<int>& target_words) const; 00025 00026 virtual int getNeuralLMId(const Word& word, bool is_source_word) const; 00027 00028 virtual void loadModel(); 00029 00030 const Word& getNullWord() const; 00031 00032 void SetParameter(const std::string& key, const std::string& value); 00033 00034 void InitializeForInput(ttasksptr const& ttask); 00035 00036 void CleanUpAfterSentenceProcessing(const InputType& source); 00037 00038 protected: 00039 oxlm::SourceFactoredLM model; 00040 boost::shared_ptr<OxLMParallelMapper> mapper; 00041 00042 bool posBackOff; 00043 FactorType posFactorType; 00044 00045 bool persistentCache; 00046 mutable boost::thread_specific_ptr<oxlm::QueryCache> cache; 00047 mutable int cacheHits, totalHits; 00048 Word NULL_word; //Null symbol for hiero 00049 }; 00050 00051 } // namespace Moses