diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-02 20:40:53 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-12-02 20:40:53 +0300 |
commit | ba7afba9f6f325441387557ab8af487d5901f023 (patch) | |
tree | 42a4372ff8cc6fe6a4136051609aac95e76b7f48 /moses/ChartManager.h | |
parent | 08c57bce870da0e74ab0cf1aff4816539dfad3c8 (diff) |
move n-best code for phrase-based from IOWrapper to ChartManager
Diffstat (limited to 'moses/ChartManager.h')
-rw-r--r-- | moses/ChartManager.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/moses/ChartManager.h b/moses/ChartManager.h index b9a6f45ba..849101b5d 100644 --- a/moses/ChartManager.h +++ b/moses/ChartManager.h @@ -32,6 +32,7 @@ #include "ChartParser.h" #include "ChartKBestExtractor.h" #include "BaseManager.h" +#include "moses/Syntax/KBestExtractor.h" #include <boost/shared_ptr.hpp> @@ -40,6 +41,7 @@ namespace Moses class ChartHypothesis; class ChartSearchGraphWriter; +class OutputCollector; /** Holds everything you need to decode 1 sentence with the hierachical/syntax decoder */ @@ -61,6 +63,32 @@ private: const ChartHypothesis *hypo, std::map<unsigned,bool> &reachable , size_t* winners, size_t* losers) const; void WriteSearchGraph(const ChartSearchGraphWriter& writer) const; + // output + typedef std::set< std::pair<size_t, size_t> > Alignments; + + void OutputNBestList(OutputCollector *collector, + const ChartKBestExtractor::KBestVec &nBestList, + long translationId); + void OutputSurface(std::ostream &out, const Phrase &phrase, const std::vector<FactorType> &outputFactorOrder, bool reportAllFactors); + size_t CalcSourceSize(const Moses::ChartHypothesis *hypo); + size_t OutputAlignmentNBest(Alignments &retAlign, + const Moses::ChartKBestExtractor::Derivation &derivation, + size_t startTarget); + + template <class T> + void ShiftOffsets(std::vector<T> &offsets, T shift) + { + T currPos = shift; + for (size_t i = 0; i < offsets.size(); ++i) { + if (offsets[i] == 0) { + offsets[i] = currPos; + ++currPos; + } else { + currPos += offsets[i]; + } + } + } + public: ChartManager(InputType const& source); ~ChartManager(); @@ -109,6 +137,8 @@ public: const ChartParser &GetParser() const { return m_parser; } + // outputs + void OutputNBest(OutputCollector *collector); }; } |