00001 /*********************************************************************** 00002 Moses - factored phrase-based language decoder 00003 Copyright (C) 2010 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 #ifndef RULEEXIST_H_INCLUDED_ 00022 #define RULEEXIST_H_INCLUDED_ 00023 00024 #include <vector> 00025 00026 #include "Hole.h" 00027 00028 namespace MosesTraining 00029 { 00030 00031 // reposity of extracted phrase pairs 00032 // which are potential holes in larger phrase pairs 00033 class RuleExist 00034 { 00035 protected: 00036 std::vector< std::vector<HoleList> > m_phraseExist; 00037 // indexed by source pos. and source length 00038 // maps to list of holes where <int, int> are target pos 00039 00040 public: 00041 RuleExist(size_t size) 00042 :m_phraseExist(size) { 00043 // size is the length of the source sentence 00044 for (size_t pos = 0; pos < size; ++pos) { 00045 // create empty hole lists 00046 std::vector<HoleList> &endVec = m_phraseExist[pos]; 00047 endVec.resize(size - pos); 00048 } 00049 } 00050 00051 void Add(int startT, int endT, int startS, int endS) { 00052 m_phraseExist[startT][endT - startT].push_back(Hole(startS, endS, startT, endT)); 00053 } 00054 00055 const HoleList &GetSourceHoles(int startT, int endT) const { 00056 const HoleList &sourceHoles = m_phraseExist[startT][endT - startT]; 00057 return sourceHoles; 00058 } 00059 00060 }; 00061 00062 } 00063 00064 00065 #endif