00001 /*********************************************************************** 00002 Moses - statistical machine translation system 00003 Copyright (C) 2006-2011 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/InputType.h" 00024 #include "moses/NonTerminal.h" 00025 #include "PhraseDictionaryNodeSCFG.h" 00026 #include "Trie.h" 00027 00028 namespace Moses 00029 { 00030 00034 class PhraseDictionarySCFG : public RuleTableTrie 00035 { 00036 friend std::ostream& operator<<(std::ostream&, const PhraseDictionarySCFG&); 00037 friend class RuleTableLoader; 00038 00039 protected: 00040 PhraseDictionarySCFG(const std::string &description, const std::string &line) 00041 : RuleTableTrie(description, line) 00042 {} 00043 00044 public: 00045 PhraseDictionarySCFG(const std::string &line) 00046 : RuleTableTrie("PhraseDictionaryMemory", line) 00047 {} 00048 00049 const PhraseDictionaryNodeSCFG &GetRootNode() const { return m_collection; } 00050 00051 ChartRuleLookupManager *CreateRuleLookupManager( 00052 const InputType &, 00053 const ChartCellCollectionBase &); 00054 00055 TO_STRING(); 00056 00057 protected: 00058 TargetPhraseCollection &GetOrCreateTargetPhraseCollection( 00059 const Phrase &source, const TargetPhrase &target, const Word *sourceLHS); 00060 const TargetPhraseCollection *GetTargetPhraseCollection(const Phrase& source) const; 00061 00062 PhraseDictionaryNodeSCFG &GetOrCreateNode(const Phrase &source 00063 , const TargetPhrase &target 00064 , const Word *sourceLHS); 00065 00066 void SortAndPrune(); 00067 00068 PhraseDictionaryNodeSCFG m_collection; 00069 }; 00070 00071 } // namespace Moses