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 "HypoList.h" 00023 #include "Word.h" 00024 #include "Range.h" 00025 #include "ChartParserCallback.h" 00026 00027 namespace search 00028 { 00029 class Vertex; 00030 } 00031 00032 namespace Moses 00033 { 00034 00035 class Word; 00036 00042 class ChartCellLabel 00043 { 00044 public: 00045 union Stack { 00046 const HypoList *cube; // cube pruning 00047 search::Vertex *incr; // incremental search after filling. 00048 void *incr_generator; // incremental search during filling. 00049 }; 00050 00051 00052 ChartCellLabel(const Range &coverage, const Word &label, 00053 Stack stack=Stack()) 00054 : m_coverage(coverage) 00055 , m_label(label) 00056 , m_stack(stack) 00057 , m_bestScore(0) { 00058 } 00059 00060 const Range &GetCoverage() const { 00061 return m_coverage; 00062 } 00063 const Word &GetLabel() const { 00064 return m_label; 00065 } 00066 Stack GetStack() const { 00067 return m_stack; 00068 } 00069 Stack &MutableStack() { 00070 return m_stack; 00071 } 00072 00073 //caching of best score on stack 00074 float GetBestScore(const ChartParserCallback *outColl) const { 00075 if (m_bestScore == 0) { 00076 m_bestScore = outColl->GetBestScore(this); 00077 } 00078 return m_bestScore; 00079 } 00080 00081 private: 00082 const Range &m_coverage; 00083 const Word &m_label; 00084 //const InputPath &m_inputPath; 00085 Stack m_stack; 00086 mutable float m_bestScore; 00087 }; 00088 00089 }