00001 // -*- c++ -*- 00002 // $Id$ 00003 // vim:tabstop=2 00004 /*********************************************************************** 00005 Moses - factored phrase-based language decoder 00006 Copyright (C) 2010 Hieu Hoang 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Lesser General Public 00010 License as published by the Free Software Foundation; either 00011 version 2.1 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public 00019 License along with this library; if not, write to the Free Software 00020 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 ***********************************************************************/ 00022 00023 #pragma once 00024 00025 #include <list> 00026 #include <vector> 00027 #include "Range.h" 00028 #include "StackVec.h" 00029 #include "InputPath.h" 00030 #include "TargetPhraseCollection.h" 00031 namespace Moses 00032 { 00033 00034 class ChartParserCallback; 00035 class ChartRuleLookupManager; 00036 class InputType; 00037 class Sentence; 00038 class ChartCellCollectionBase; 00039 class Word; 00040 class Phrase; 00041 // class TargetPhraseCollection; 00042 class DecodeGraph; 00043 00044 class ChartParserUnknown 00045 { 00046 ttaskwptr m_ttask; 00047 public: 00048 ChartParserUnknown(ttasksptr const& ttask); 00049 ~ChartParserUnknown(); 00050 00051 void Process(const Word &sourceWord, const Range &range, ChartParserCallback &to); 00052 00053 const std::vector<Phrase*> &GetUnknownSources() const { 00054 return m_unksrcs; 00055 } 00056 00057 private: 00058 std::vector<Phrase*> m_unksrcs; 00059 std::list<TargetPhraseCollection::shared_ptr> m_cacheTargetPhraseCollection; 00060 AllOptions::ptr const& options() const; 00061 }; 00062 00063 class ChartParser 00064 { 00065 ttaskwptr m_ttask; 00066 public: 00067 ChartParser(ttasksptr const& ttask, ChartCellCollectionBase &cells); 00068 ~ChartParser(); 00069 00070 void Create(const Range &range, ChartParserCallback &to); 00071 00073 //const Sentence &GetSentence() const; 00074 long GetTranslationId() const; 00075 size_t GetSize() const; 00076 const InputPath &GetInputPath(size_t startPos, size_t endPos) const; 00077 const InputPath &GetInputPath(const Range &range) const; 00078 const std::vector<Phrase*> &GetUnknownSources() const { 00079 return m_unknown.GetUnknownSources(); 00080 } 00081 00082 AllOptions::ptr const& options() const; 00083 00084 private: 00085 ChartParserUnknown m_unknown; 00086 std::vector <DecodeGraph*> m_decodeGraphList; 00087 std::vector<ChartRuleLookupManager*> m_ruleLookupManagers; 00088 InputType const& m_source; 00090 typedef std::vector< std::vector<InputPath*> > InputPathMatrix; 00091 InputPathMatrix m_inputPathMatrix; 00092 00093 void CreateInputPaths(const InputType &input); 00094 InputPath &GetInputPath(size_t startPos, size_t endPos); 00095 00096 }; 00097 00098 } 00099