00001 // $Id$ 00002 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 00022 #ifndef moses_GenerationDictionary_h 00023 #define moses_GenerationDictionary_h 00024 00025 #include <list> 00026 #include <stdexcept> 00027 #include <vector> 00028 #include <boost/unordered_map.hpp> 00029 #include "ScoreComponentCollection.h" 00030 #include "Phrase.h" 00031 #include "TypeDef.h" 00032 #include "moses/FF/DecodeFeature.h" 00033 00034 namespace Moses 00035 { 00036 00037 class FactorCollection; 00038 00039 typedef boost::unordered_map < Word , ScoreComponentCollection > OutputWordCollection; 00040 // 1st = output phrase 00041 // 2nd = log probability (score) 00042 00045 class GenerationDictionary : public DecodeFeature 00046 { 00047 typedef boost::unordered_map<const Word* , OutputWordCollection, UnorderedComparer<Word>, UnorderedComparer<Word> > Collection; 00048 protected: 00049 static std::vector<GenerationDictionary*> s_staticColl; 00050 00051 Collection m_collection; 00052 // 1st = source 00053 // 2nd = target 00054 std::string m_filePath; 00055 00056 public: 00057 static const std::vector<GenerationDictionary*>& GetColl() { 00058 return s_staticColl; 00059 } 00060 00061 GenerationDictionary(const std::string &line); 00062 virtual ~GenerationDictionary(); 00063 00065 void Load(AllOptions::ptr const& opts); 00066 00070 size_t GetSize() const { 00071 return m_collection.size(); 00072 } 00076 const OutputWordCollection *FindWord(const Word &word) const; 00077 void SetParameter(const std::string& key, const std::string& value); 00078 00079 }; 00080 00081 00082 } 00083 #endif