2014-12-02 17:38:03 +03:00
|
|
|
#pragma once
|
|
|
|
|
2014-12-02 20:40:53 +03:00
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include "ScoreComponentCollection.h"
|
2014-12-06 00:33:59 +03:00
|
|
|
#include "InputType.h"
|
2014-12-02 20:40:53 +03:00
|
|
|
|
2014-12-02 17:38:03 +03:00
|
|
|
namespace Moses
|
|
|
|
{
|
2014-12-02 20:40:53 +03:00
|
|
|
class ScoreComponentCollection;
|
|
|
|
class FeatureFunction;
|
2014-12-02 22:09:10 +03:00
|
|
|
class OutputCollector;
|
2014-12-02 20:40:53 +03:00
|
|
|
|
2014-12-02 17:38:03 +03:00
|
|
|
class BaseManager
|
|
|
|
{
|
2014-12-02 20:40:53 +03:00
|
|
|
protected:
|
2014-12-06 00:33:59 +03:00
|
|
|
const InputType &m_source; /**< source sentence to be translated */
|
|
|
|
|
|
|
|
BaseManager(const InputType &source)
|
2015-01-14 14:07:42 +03:00
|
|
|
:m_source(source) {
|
|
|
|
}
|
2014-12-04 17:11:49 +03:00
|
|
|
|
|
|
|
// output
|
2014-12-03 20:04:10 +03:00
|
|
|
typedef std::vector<std::pair<Moses::Word, Moses::WordsRange> > ApplicationContext;
|
2014-12-04 17:11:49 +03:00
|
|
|
typedef std::set< std::pair<size_t, size_t> > Alignments;
|
2014-12-03 20:04:10 +03:00
|
|
|
|
2014-12-02 22:09:10 +03:00
|
|
|
void OutputSurface(std::ostream &out,
|
2015-01-14 14:07:42 +03:00
|
|
|
const Phrase &phrase,
|
|
|
|
const std::vector<FactorType> &outputFactorOrder,
|
|
|
|
bool reportAllFactors) const;
|
2014-12-03 20:04:10 +03:00
|
|
|
void WriteApplicationContext(std::ostream &out,
|
2015-01-14 14:07:42 +03:00
|
|
|
const ApplicationContext &context) const;
|
2014-12-04 17:11:49 +03:00
|
|
|
|
|
|
|
template <class T>
|
2015-01-14 14:07:42 +03:00
|
|
|
void ShiftOffsets(std::vector<T> &offsets, T shift) const {
|
2014-12-04 17:11:49 +03:00
|
|
|
T currPos = shift;
|
|
|
|
for (size_t i = 0; i < offsets.size(); ++i) {
|
|
|
|
if (offsets[i] == 0) {
|
|
|
|
offsets[i] = currPos;
|
|
|
|
++currPos;
|
|
|
|
} else {
|
|
|
|
currPos += offsets[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-12-02 22:09:10 +03:00
|
|
|
|
|
|
|
public:
|
2015-01-14 14:07:42 +03:00
|
|
|
virtual ~BaseManager() {
|
|
|
|
}
|
2015-01-04 13:02:44 +03:00
|
|
|
|
2014-12-06 00:33:59 +03:00
|
|
|
//! the input sentence being decoded
|
|
|
|
const InputType& GetSource() const {
|
|
|
|
return m_source;
|
|
|
|
}
|
|
|
|
|
2014-12-05 20:59:53 +03:00
|
|
|
virtual void Decode() = 0;
|
2014-12-02 22:09:10 +03:00
|
|
|
// outputs
|
2015-01-04 13:02:44 +03:00
|
|
|
virtual void OutputBest(OutputCollector *collector) const = 0;
|
2014-12-02 22:09:10 +03:00
|
|
|
virtual void OutputNBest(OutputCollector *collector) const = 0;
|
2014-12-03 15:05:35 +03:00
|
|
|
virtual void OutputLatticeSamples(OutputCollector *collector) const = 0;
|
2014-12-03 18:00:36 +03:00
|
|
|
virtual void OutputAlignment(OutputCollector *collector) const = 0;
|
2014-12-03 20:04:10 +03:00
|
|
|
virtual void OutputDetailedTranslationReport(OutputCollector *collector) const = 0;
|
2014-12-04 21:35:19 +03:00
|
|
|
virtual void OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const = 0;
|
2014-12-05 20:23:08 +03:00
|
|
|
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;
|
2014-12-05 22:40:51 +03:00
|
|
|
virtual void OutputSearchGraphSLF() const = 0;
|
2014-12-06 00:33:59 +03:00
|
|
|
virtual void OutputSearchGraphHypergraph() const = 0;
|
2014-12-03 15:05:35 +03:00
|
|
|
|
2015-01-04 13:02:44 +03:00
|
|
|
/***
|
|
|
|
* to be called after processing a sentence
|
|
|
|
*/
|
|
|
|
virtual void CalcDecoderStatistics() const = 0;
|
2014-12-02 17:38:03 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|