2015-03-26 21:25:54 +03:00
|
|
|
// -*- c++ -*-
|
2012-10-11 19:38:39 +04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "lm/word_index.hh"
|
2012-11-16 18:46:10 +04:00
|
|
|
#include "search/applied.hh"
|
|
|
|
#include "search/nbest.hh"
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2012-11-12 23:56:18 +04:00
|
|
|
#include "moses/ChartCellCollection.h"
|
|
|
|
#include "moses/ChartParser.h"
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2014-12-02 17:38:03 +03:00
|
|
|
#include "BaseManager.h"
|
|
|
|
|
2012-11-15 22:24:21 +04:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
namespace Moses
|
|
|
|
{
|
2012-11-16 18:46:10 +04:00
|
|
|
class ScoreComponentCollection;
|
2012-10-11 19:38:39 +04:00
|
|
|
class InputType;
|
2013-05-27 18:54:50 +04:00
|
|
|
class LanguageModel;
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
namespace Incremental
|
|
|
|
{
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2014-12-02 17:38:03 +03:00
|
|
|
class Manager : public BaseManager
|
2013-05-29 21:16:15 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-03-26 21:25:54 +03:00
|
|
|
Manager(ttasksptr const& ttask);
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
~Manager();
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
template <class Model> void LMCallback(const Model &model, const std::vector<lm::WordIndex> &words);
|
2012-10-11 19:38:39 +04:00
|
|
|
|
2014-12-05 20:59:53 +03:00
|
|
|
void Decode();
|
|
|
|
|
|
|
|
const std::vector<search::Applied> &GetNBest() const;
|
2012-10-12 16:53:08 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
// Call to get the same value as ProcessSentence returned.
|
|
|
|
const std::vector<search::Applied> &Completed() const {
|
|
|
|
return *completed_nbest_;
|
|
|
|
}
|
2012-11-16 18:46:10 +04:00
|
|
|
|
2014-12-02 22:09:10 +03:00
|
|
|
// output
|
2014-12-10 14:28:47 +03:00
|
|
|
void OutputBest(OutputCollector *collector) const;
|
2014-12-02 22:09:10 +03:00
|
|
|
void OutputNBest(OutputCollector *collector) const;
|
2014-12-03 20:04:10 +03:00
|
|
|
void OutputDetailedTranslationReport(OutputCollector *collector) const;
|
|
|
|
void OutputNBestList(OutputCollector *collector, const std::vector<search::Applied> &nbest, long translationId) const;
|
2015-01-14 14:07:42 +03:00
|
|
|
void OutputLatticeSamples(OutputCollector *collector) const {
|
|
|
|
}
|
|
|
|
void OutputAlignment(OutputCollector *collector) const {
|
|
|
|
}
|
2014-12-04 21:35:19 +03:00
|
|
|
void OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const;
|
2015-01-14 14:07:42 +03:00
|
|
|
void OutputWordGraph(OutputCollector *collector) const {
|
|
|
|
}
|
|
|
|
void OutputSearchGraph(OutputCollector *collector) const {
|
|
|
|
}
|
|
|
|
void OutputSearchGraphSLF() const {
|
|
|
|
}
|
|
|
|
void OutputSearchGraphHypergraph() const {
|
|
|
|
}
|
2014-12-02 22:09:10 +03:00
|
|
|
|
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
private:
|
|
|
|
template <class Model, class Best> search::History PopulateBest(const Model &model, const std::vector<lm::WordIndex> &words, Best &out);
|
2012-10-12 16:53:08 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
ChartCellCollectionBase cells_;
|
|
|
|
ChartParser parser_;
|
2012-11-16 18:46:10 +04:00
|
|
|
|
2013-05-29 21:16:15 +04:00
|
|
|
// Only one of single_best_ or n_best_ will be used, but it was easier to do this than a template.
|
|
|
|
search::SingleBest single_best_;
|
|
|
|
// ProcessSentence returns a reference to a vector. ProcessSentence
|
|
|
|
// doesn't have one, so this is populated and returned.
|
|
|
|
std::vector<search::Applied> backing_for_single_;
|
|
|
|
|
|
|
|
search::NBest n_best_;
|
|
|
|
|
|
|
|
const std::vector<search::Applied> *completed_nbest_;
|
2014-12-02 22:09:10 +03:00
|
|
|
|
|
|
|
// outputs
|
2014-12-03 20:04:10 +03:00
|
|
|
void OutputDetailedTranslationReport(
|
2015-01-14 14:07:42 +03:00
|
|
|
OutputCollector *collector,
|
|
|
|
const search::Applied *applied,
|
|
|
|
const Sentence &sentence,
|
|
|
|
long translationId) const;
|
|
|
|
void OutputTranslationOptions(std::ostream &out,
|
|
|
|
ApplicationContext &applicationContext,
|
|
|
|
const search::Applied *applied,
|
|
|
|
const Sentence &sentence,
|
|
|
|
long translationId) const;
|
|
|
|
void OutputTranslationOption(std::ostream &out,
|
|
|
|
ApplicationContext &applicationContext,
|
|
|
|
const search::Applied *applied,
|
|
|
|
const Sentence &sentence,
|
|
|
|
long translationId) const;
|
|
|
|
void ReconstructApplicationContext(const search::Applied *applied,
|
|
|
|
const Sentence &sentence,
|
|
|
|
ApplicationContext &context) const;
|
|
|
|
void OutputTreeFragmentsTranslationOptions(std::ostream &out,
|
|
|
|
ApplicationContext &applicationContext,
|
2014-12-03 20:04:10 +03:00
|
|
|
const search::Applied *applied,
|
|
|
|
const Sentence &sentence,
|
|
|
|
long translationId) const;
|
2015-01-14 14:07:42 +03:00
|
|
|
void OutputBestHypo(OutputCollector *collector, search::Applied applied, long translationId) const;
|
|
|
|
void OutputBestNone(OutputCollector *collector, long translationId) const;
|
|
|
|
|
|
|
|
void OutputUnknowns(OutputCollector *collector) const {
|
|
|
|
}
|
|
|
|
void CalcDecoderStatistics() const {
|
|
|
|
}
|
2015-01-04 13:02:44 +03:00
|
|
|
|
2012-10-11 19:38:39 +04:00
|
|
|
};
|
2012-11-16 18:46:10 +04:00
|
|
|
|
|
|
|
// Just get the phrase.
|
|
|
|
void ToPhrase(const search::Applied final, Phrase &out);
|
2013-05-29 21:16:15 +04:00
|
|
|
// Get the phrase and the features.
|
2013-05-11 17:13:26 +04:00
|
|
|
void PhraseAndFeatures(const search::Applied final, Phrase &phrase, ScoreComponentCollection &features);
|
2012-11-16 18:46:10 +04:00
|
|
|
|
2013-05-27 18:54:50 +04:00
|
|
|
|
2012-10-11 19:38:39 +04:00
|
|
|
} // namespace Incremental
|
|
|
|
} // namespace Moses
|
|
|
|
|