00001 #pragma once 00002 00003 #include <boost/unordered_set.hpp> 00004 #include "moses/InputType.h" 00005 #include "moses/BaseManager.h" 00006 00007 #include "KBestExtractor.h" 00008 00009 namespace Moses 00010 { 00011 namespace Syntax 00012 { 00013 00014 // Common base class for Moses::Syntax managers. 00015 class Manager : public BaseManager 00016 { 00017 public: 00018 Manager(ttasksptr const& ttask); 00019 00020 // Virtual functions from Moses::BaseManager that are implemented the same 00021 // way for all Syntax managers. 00022 void OutputBest(OutputCollector *collector) const; 00023 void OutputNBest(OutputCollector *collector) const; 00024 void OutputUnknowns(OutputCollector *collector) const; 00025 00026 // Virtual functions from Moses::BaseManager that are no-ops for all Syntax 00027 // managers. 00028 void OutputAlignment(OutputCollector *collector) const {} 00029 void OutputDetailedTreeFragmentsTranslationReport( 00030 OutputCollector *collector) const {} 00031 void OutputLatticeSamples(OutputCollector *collector) const {} 00032 void OutputSearchGraph(OutputCollector *collector) const {} 00033 // void OutputSearchGraphHypergraph() const {} 00034 00035 void 00036 OutputSearchGraphAsHypergraph 00037 ( std::string const& fname, size_t const precision ) const 00038 { } 00039 00040 void OutputSearchGraphSLF() const {} 00041 void OutputWordGraph(OutputCollector *collector) const {} 00042 void OutputDetailedTranslationReport(OutputCollector *collector) const {} 00043 00044 void CalcDecoderStatistics() const {} 00045 00046 // Syntax-specific virtual functions that derived classes must implement. 00047 virtual void ExtractKBest( 00048 std::size_t k, 00049 std::vector<boost::shared_ptr<KBestExtractor::Derivation> > &kBestList, 00050 bool onlyDistinct=false) const = 0; 00051 virtual const SHyperedge *GetBestSHyperedge() const = 0; 00052 00053 protected: 00054 boost::unordered_set<Word> m_oovs; 00055 00056 private: 00057 // Syntax-specific helper functions used to implement OutputNBest. 00058 void OutputNBestList(OutputCollector *collector, 00059 const KBestExtractor::KBestVec &nBestList, 00060 long translationId) const; 00061 00062 std::size_t OutputAlignmentNBest(Alignments &retAlign, 00063 const KBestExtractor::Derivation &d, 00064 std::size_t startTarget) const; 00065 00066 std::size_t CalcSourceSize(const KBestExtractor::Derivation &d) const; 00067 }; 00068 00069 } // Syntax 00070 } // Moses