2015-03-26 19:37:04 +03:00
|
|
|
// -*- c++ -*-
|
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"
|
2015-08-06 02:51:02 +03:00
|
|
|
#include "moses/parameters/AllOptions.h"
|
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:
|
2015-03-26 19:37:04 +03:00
|
|
|
// const InputType &m_source; /**< source sentence to be translated */
|
|
|
|
ttaskwptr m_ttask;
|
2015-04-30 08:05:11 +03:00
|
|
|
InputType const& m_source;
|
|
|
|
|
|
|
|
BaseManager(ttasksptr const& ttask);
|
2014-12-04 17:11:49 +03:00
|
|
|
|
|
|
|
// output
|
2015-10-25 16:37:59 +03:00
|
|
|
typedef std::vector<std::pair<Moses::Word, Moses::Range> > 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
|
|
|
|
2015-12-02 23:43:56 +03:00
|
|
|
void OutputSurface(std::ostream &out, Phrase const& phrase) 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-03-26 19:37:04 +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
|
2015-03-27 02:38:58 +03:00
|
|
|
const InputType& GetSource() const;
|
2015-07-02 03:32:34 +03:00
|
|
|
const ttasksptr GetTtask() const;
|
2015-08-06 02:51:02 +03:00
|
|
|
AllOptions const& options() const;
|
2014-12-06 00:33:59 +03:00
|
|
|
|
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;
|
2015-05-12 04:28:58 +03:00
|
|
|
// virtual void OutputSearchGraphHypergraph() const = 0;
|
2014-12-03 15:05:35 +03:00
|
|
|
|
2015-05-12 04:28:58 +03:00
|
|
|
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
|
|
|
|
2014-12-02 17:38:03 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|