00001 #pragma once 00002 00003 #include <vector> 00004 00005 #include <boost/shared_ptr.hpp> 00006 #include <boost/unordered_map.hpp> 00007 #include <boost/unordered_set.hpp> 00008 00009 #include "moses/InputType.h" 00010 #include "moses/Syntax/KBestExtractor.h" 00011 #include "moses/Syntax/Manager.h" 00012 #include "moses/Syntax/SVertexStack.h" 00013 #include "moses/Word.h" 00014 00015 #include "Forest.h" 00016 #include "HyperTree.h" 00017 #include "PVertexToStackMap.h" 00018 00019 namespace Moses 00020 { 00021 namespace Syntax 00022 { 00023 00024 struct SHyperedge; 00025 00026 namespace F2S 00027 { 00028 00029 template<typename RuleMatcher> 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 typedef std::vector<boost::shared_ptr<KBestExtractor::Derivation> > kBestList_t; 00041 void ExtractKBest(std::size_t k, kBestList_t& kBestList, 00042 bool onlyDistinct=false) const; 00043 00044 void OutputDetailedTranslationReport(OutputCollector *collector) const; 00045 00046 private: 00047 const Forest::Vertex &FindRootNode(const Forest &); 00048 00049 void InitializeRuleMatchers(); 00050 00051 void InitializeStacks(); 00052 00053 bool IsUnknownSourceWord(const Word &) const; 00054 00055 void RecombineAndSort(const std::vector<SHyperedge*> &, SVertexStack &); 00056 00057 boost::shared_ptr<const Forest> m_forest; 00058 const Forest::Vertex *m_rootVertex; 00059 std::size_t m_sentenceLength; // Includes <s> and </s> 00060 PVertexToStackMap m_stackMap; 00061 boost::shared_ptr<HyperTree> m_glueRuleTrie; 00062 std::vector<boost::shared_ptr<RuleMatcher> > m_mainRuleMatchers; 00063 boost::shared_ptr<RuleMatcher> m_glueRuleMatcher; 00064 }; 00065 00066 } // F2S 00067 } // Syntax 00068 } // Moses 00069 00070 // Implementation 00071 #include "Manager-inl.h"