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 "Trie.h" 00023 #include "moses/TypeDef.h" 00024 #include "moses/parameters/AllOptions.h" 00025 00026 #include <istream> 00027 #include <vector> 00028 00029 namespace Moses 00030 { 00031 00034 class RuleTableLoader 00035 { 00036 public: 00037 virtual ~RuleTableLoader() {} 00038 00039 virtual bool Load(AllOptions const& opts, 00040 const std::vector<FactorType> &input, 00041 const std::vector<FactorType> &output, 00042 const std::string &inFile, 00043 size_t tableLimit, 00044 RuleTableTrie &) = 0; 00045 00046 protected: 00047 // Provide access to RuleTableTrie's private SortAndPrune function. 00048 void SortAndPrune(RuleTableTrie &ruleTable) { 00049 ruleTable.SortAndPrune(); 00050 } 00051 00052 // Provide access to RuleTableTrie's private 00053 // GetOrCreateTargetPhraseCollection function. 00054 TargetPhraseCollection::shared_ptr 00055 GetOrCreateTargetPhraseCollection(RuleTableTrie &ruleTable, 00056 const Phrase &source, 00057 const TargetPhrase &target, 00058 const Word *sourceLHS) { 00059 return ruleTable.GetOrCreateTargetPhraseCollection(source, target, 00060 sourceLHS); 00061 } 00062 }; 00063 00064 } // namespace Moses