00001 #pragma once 00002 00003 #include <set> 00004 #include <vector> 00005 00006 #include <boost/shared_ptr.hpp> 00007 00008 #include "moses/InputType.h" 00009 #include "moses/Syntax/KBestExtractor.h" 00010 #include "moses/Syntax/Manager.h" 00011 #include "moses/Syntax/SVertexStack.h" 00012 #include "moses/Word.h" 00013 00014 #include "OovHandler.h" 00015 #include "ParserCallback.h" 00016 #include "PChart.h" 00017 #include "SChart.h" 00018 00019 namespace Moses 00020 { 00021 namespace Syntax 00022 { 00023 00024 struct SHyperedge; 00025 00026 namespace S2T 00027 { 00028 00029 template<typename Parser> 00030 class Manager : public Syntax::Manager 00031 { 00032 public: 00033 Manager(ttasksptr const& ttask); 00034 00035 void Decode(); 00036 00037 // Get the SHyperedge for the 1-best derivation. 00038 const SHyperedge *GetBestSHyperedge() const; 00039 00040 void ExtractKBest( 00041 std::size_t k, 00042 std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList, 00043 bool onlyDistinct=false) const; 00044 00045 void OutputDetailedTranslationReport(OutputCollector *collector) const; 00046 00047 private: 00048 void FindOovs(const PChart &, boost::unordered_set<Word> &, std::size_t); 00049 00050 void InitializeCharts(); 00051 00052 void InitializeParsers(PChart &, std::size_t); 00053 00054 void RecombineAndSort(const std::vector<SHyperedge*> &, SVertexStack &); 00055 00056 void PrunePChart(const SChart::Cell &, PChart::Cell &); 00057 00058 PChart m_pchart; 00059 SChart m_schart; 00060 boost::shared_ptr<typename Parser::RuleTrie> m_oovRuleTrie; 00061 std::vector<boost::shared_ptr<Parser> > m_parsers; 00062 }; 00063 00064 } // S2T 00065 } // Syntax 00066 } // Moses 00067 00068 // Implementation 00069 #include "Manager-inl.h"