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 "PhraseDictionaryNodeMemory.h" 00023 #include "moses/TranslationModel/PhraseDictionary.h" 00024 #include "moses/InputType.h" 00025 #include "moses/NonTerminal.h" 00026 #include "moses/TranslationModel/RuleTable/Trie.h" 00027 00028 namespace Moses 00029 { 00030 class ChartParser; 00031 00035 class PhraseDictionaryMemory : public RuleTableTrie 00036 { 00037 friend std::ostream& operator<<(std::ostream&, const PhraseDictionaryMemory&); 00038 friend class RuleTableLoader; 00039 00040 protected: 00041 PhraseDictionaryMemory(int type, const std::string &line) 00042 : RuleTableTrie(line) { 00043 } 00044 00045 public: 00046 PhraseDictionaryMemory(const std::string &line); 00047 00048 const PhraseDictionaryNodeMemory &GetRootNode() const { 00049 return m_collection; 00050 } 00051 00052 ChartRuleLookupManager* 00053 CreateRuleLookupManager( 00054 const ChartParser &, 00055 const ChartCellCollectionBase &, 00056 std::size_t); 00057 00058 // only used by multi-model phrase table, and other meta-features 00059 TargetPhraseCollection::shared_ptr 00060 GetTargetPhraseCollectionLEGACY(const Phrase& src) const; 00061 00062 void 00063 GetTargetPhraseCollectionBatch(const InputPathList &inputPathQueue) const; 00064 00065 TO_STRING(); 00066 00067 protected: 00068 TargetPhraseCollection::shared_ptr 00069 GetOrCreateTargetPhraseCollection 00070 (const Phrase &source, const TargetPhrase &target, const Word *sourceLHS); 00071 00072 PhraseDictionaryNodeMemory & 00073 GetOrCreateNode(const Phrase &source, const TargetPhrase &target, 00074 const Word *sourceLHS); 00075 00076 void SortAndPrune(); 00077 00078 PhraseDictionaryNodeMemory m_collection; 00079 }; 00080 00081 } // namespace Moses