00001 #ifndef moses_LM_Rand_h 00002 #define moses_LM_Rand_h 00003 /*********************************************************************** 00004 Moses - factored phrase-based language decoder 00005 Copyright (C) 2006 University of Edinburgh 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2.1 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 ***********************************************************************/ 00021 #include <vector> 00022 #include <string> 00023 #include <stdint.h> 00024 #include "SingleFactor.h" 00025 #include "moses/TypeDef.h" 00026 #include "moses/Word.h" 00027 //#include "RandLM.h" 00028 00029 namespace randlm 00030 { 00031 class RandLM; 00032 } 00033 00034 namespace Moses 00035 { 00036 class LanguageModelRandLM : public LanguageModelSingleFactor 00037 { 00038 public: 00039 LanguageModelRandLM(const std::string &line); 00040 ~LanguageModelRandLM(); 00041 00042 void Load(AllOptions::ptr const& opts); 00043 virtual LMResult GetValue(const std::vector<const Word*> &contextFactor, State* finalState = NULL) const; 00044 void InitializeForInput(ttasksptr const& ttask); 00045 void CleanUpAfterSentenceProcessing(const InputType& source); 00046 00047 protected: 00048 //std::vector<randlm::WordID> m_randlm_ids_vec; 00049 std::vector<uint32_t> m_randlm_ids_vec; // Ken made me do this 00050 00051 randlm::RandLM* m_lm; 00052 uint32_t m_oov_id; 00053 void CreateFactors(FactorCollection &factorCollection); 00054 uint32_t GetLmID( const std::string &str ) const; 00055 uint32_t GetLmID( const Factor *factor ) const; 00056 00057 }; 00058 00059 } 00060 00061 #endif