00001 /*********************************************************************** 00002 Moses - statistical machine translation system 00003 Copyright (C) 2006-2012 University of Edinburgh 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Lesser General Public License for more details. 00014 00015 You should have received a copy of the GNU Lesser General Public 00016 License along with this library; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 ***********************************************************************/ 00019 00020 #pragma once 00021 00022 #include "moses/TranslationModel/PhraseDictionary.h" 00023 #include "moses/TypeDef.h" 00024 00025 #include <string> 00026 #include <vector> 00027 00028 namespace Moses 00029 { 00030 00031 class Phrase; 00032 class TargetPhrase; 00033 class TargetPhraseCollection; 00034 class Word; 00035 00036 /*** Implementation of a SCFG rule table in a trie. Looking up a rule of 00037 * length n symbols requires n look-ups to find the TargetPhraseCollection. 00038 * @todo why need this and PhraseDictionaryMemory? 00039 */ 00040 class RuleTableTrie : public PhraseDictionary 00041 { 00042 public: 00043 RuleTableTrie(const std::string &line) 00044 : PhraseDictionary(line, true) { 00045 } 00046 00047 virtual ~RuleTableTrie(); 00048 00049 void Load(AllOptions::ptr const& opts); 00050 00051 private: 00052 friend class RuleTableLoader; 00053 00054 virtual TargetPhraseCollection::shared_ptr 00055 GetOrCreateTargetPhraseCollection(const Phrase &source, 00056 const TargetPhrase &target, 00057 const Word *sourceLHS) = 0; 00058 00059 virtual void SortAndPrune() = 0; 00060 00061 }; 00062 00063 } // namespace Moses