00001 // $Id$ 00002 /*********************************************************************** 00003 Moses - factored phrase-based language decoder 00004 Copyright (C) 2010 Hieu Hoang 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 ***********************************************************************/ 00020 #include <algorithm> 00021 #include "DotChartOnDisk.h" 00022 #include "moses/Util.h" 00023 #include "OnDiskPt/PhraseNode.h" 00024 00025 using namespace std; 00026 00027 namespace Moses 00028 { 00029 DottedRuleStackOnDisk::DottedRuleStackOnDisk(size_t size) 00030 :m_coll(size) 00031 { 00032 for (size_t ind = 0; ind < size; ++ind) { 00033 m_coll[ind] = new DottedRuleCollOnDisk(); 00034 } 00035 } 00036 00037 DottedRuleStackOnDisk::~DottedRuleStackOnDisk() 00038 { 00039 RemoveAllInColl(m_coll); 00040 RemoveAllInColl(m_savedNode); 00041 } 00042 00043 class SavedNodesOderer 00044 { 00045 public: 00046 bool operator()(const SavedNodeOnDisk* a, const SavedNodeOnDisk* b) const { 00047 bool ret = a->GetDottedRule().GetLastNode().GetCount(0) > b->GetDottedRule().GetLastNode().GetCount(0); 00048 return ret; 00049 } 00050 }; 00051 00052 void DottedRuleStackOnDisk::SortSavedNodes() 00053 { 00054 sort(m_savedNode.begin(), m_savedNode.end(), SavedNodesOderer()); 00055 } 00056 00057 };