mosesdecoder/moses/BaseManager.h

79 lines
2.4 KiB
C
Raw Normal View History

// -*- c++ -*-
#pragma once
#include <iostream>
#include <string>
#include "ScoreComponentCollection.h"
#include "InputType.h"
#include "moses/parameters/AllOptions.h"
namespace Moses
{
class ScoreComponentCollection;
class FeatureFunction;
class OutputCollector;
class BaseManager
{
protected:
// const InputType &m_source; /**< source sentence to be translated */
ttaskwptr m_ttask;
InputType const& m_source;
BaseManager(ttasksptr const& ttask);
// output
2015-10-25 16:37:59 +03:00
typedef std::vector<std::pair<Moses::Word, Moses::Range> > ApplicationContext;
typedef std::set< std::pair<size_t, size_t> > Alignments;
void OutputSurface(std::ostream &out, Phrase const& phrase) const;
void WriteApplicationContext(std::ostream &out,
2015-01-14 14:07:42 +03:00
const ApplicationContext &context) const;
template <class T>
2015-01-14 14:07:42 +03:00
void ShiftOffsets(std::vector<T> &offsets, T shift) const {
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:
virtual ~BaseManager() { }
2015-01-04 13:02:44 +03:00
//! the input sentence being decoded
const InputType& GetSource() const;
const ttasksptr GetTtask() const;
AllOptions const& options() const;
2014-12-05 20:59:53 +03:00
virtual void Decode() = 0;
// outputs
2015-01-04 13:02:44 +03:00
virtual void OutputBest(OutputCollector *collector) const = 0;
virtual void OutputNBest(OutputCollector *collector) const = 0;
virtual void OutputLatticeSamples(OutputCollector *collector) const = 0;
2014-12-03 18:00:36 +03:00
virtual void OutputAlignment(OutputCollector *collector) const = 0;
virtual void OutputDetailedTranslationReport(OutputCollector *collector) const = 0;
virtual void OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const = 0;
virtual void OutputWordGraph(OutputCollector *collector) const = 0;
virtual void OutputSearchGraph(OutputCollector *collector) const = 0;
2015-01-04 13:02:44 +03:00
virtual void OutputUnknowns(OutputCollector *collector) const = 0;
virtual void OutputSearchGraphSLF() const = 0;
// virtual void OutputSearchGraphHypergraph() const = 0;
virtual void OutputSearchGraphAsHypergraph(std::ostream& out) const;
2015-05-13 13:29:16 +03:00
virtual void OutputSearchGraphAsHypergraph(std::string const& fname,
size_t const precision) const;
2015-01-04 13:02:44 +03:00
/***
* to be called after processing a sentence
*/
virtual void CalcDecoderStatistics() const = 0;
2015-05-13 13:29:16 +03:00
};
}