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 #pragma once 00021 00022 #include "moses/ChartCellLabel.h" 00023 00024 namespace Moses 00025 { 00026 00029 class DottedRule 00030 { 00031 public: 00032 // used only to init dot stack. 00033 DottedRule() 00034 : m_cellLabel(NULL) 00035 , m_prev(NULL) {} 00036 00037 DottedRule(const ChartCellLabel &ccl, const DottedRule &prev) 00038 : m_cellLabel(&ccl) 00039 , m_prev(&prev) {} 00040 00041 const Range &GetWordsRange() const { 00042 return m_cellLabel->GetCoverage(); 00043 } 00044 const Word &GetSourceWord() const { 00045 return m_cellLabel->GetLabel(); 00046 } 00047 bool IsNonTerminal() const { 00048 return m_cellLabel->GetLabel().IsNonTerminal(); 00049 } 00050 const DottedRule *GetPrev() const { 00051 return m_prev; 00052 } 00053 bool IsRoot() const { 00054 return m_prev == NULL; 00055 } 00056 const ChartCellLabel &GetChartCellLabel() const { 00057 return *m_cellLabel; 00058 } 00059 00060 private: 00061 const ChartCellLabel *m_cellLabel; // usually contains something, unless 00062 // it's the init processed rule 00063 const DottedRule *m_prev; 00064 }; 00065 00066 }