#include <IOWrapper.h>
Public Member Functions | |
IOWrapper (const std::vector< Moses::FactorType > &inputFactorOrder, const std::vector< Moses::FactorType > &outputFactorOrder, const Moses::FactorMask &inputFactorUsed, size_t nBestSize, const std::string &nBestFilePath, const std::string &inputFilePath="") | |
~IOWrapper () | |
Moses::InputType * | GetInput (Moses::InputType *inputType) |
void | OutputBestHypo (const Moses::ChartHypothesis *hypo, long translationId) |
void | OutputBestHypo (search::Applied applied, long translationId) |
void | OutputBestHypo (const std::vector< const Moses::Factor * > &mbrBestHypo, long translationId) |
void | OutputBestNone (long translationId) |
void | OutputNBestList (const Moses::ChartTrellisPathList &nBestList, long translationId) |
void | OutputNBestList (const std::vector< search::Applied > &nbest, long translationId) |
void | OutputDetailedTranslationReport (const Moses::ChartHypothesis *hypo, const Moses::Sentence &sentence, long translationId) |
void | Backtrack (const Moses::ChartHypothesis *hypo) |
void | ResetTranslationId () |
Moses::OutputCollector * | GetSearchGraphOutputCollector () |
void | OutputAlignment (size_t translationId, const Moses::ChartHypothesis *hypo) |
Static Public Member Functions | |
static void | FixPrecision (std::ostream &, size_t size=3) |
Protected Types | |
typedef std::vector< std::pair < Moses::Word, Moses::WordsRange > > | ApplicationContext |
typedef std::set< std::pair < size_t, size_t > > | Alignments |
Protected Member Functions | |
size_t | OutputAlignmentNBest (Alignments &retAlign, const Moses::ChartTrellisNode &node, size_t startTarget) |
size_t | OutputAlignment (Alignments &retAlign, const Moses::ChartHypothesis *hypo, size_t startTarget) |
void | OutputAlignment (std::vector< std::set< size_t > > &retAlignmentsS2T, const Moses::AlignmentInfo &ai) |
void | OutputTranslationOptions (std::ostream &out, ApplicationContext &applicationContext, const Moses::ChartHypothesis *hypo, const Moses::Sentence &sentence, long translationId) |
void | ReconstructApplicationContext (const Moses::ChartHypothesis &hypo, const Moses::Sentence &sentence, ApplicationContext &context) |
void | WriteApplicationContext (std::ostream &out, const ApplicationContext &context) |
void | OutputAllFeatureScores (const Moses::ScoreComponentCollection &features, std::ostream &out) |
void | OutputFeatureScores (std::ostream &out, const Moses::ScoreComponentCollection &features, const Moses::FeatureFunction *ff, std::string &lastName) |
Protected Attributes | |
long | m_translationId |
const std::vector < Moses::FactorType > & | m_inputFactorOrder |
const std::vector < Moses::FactorType > & | m_outputFactorOrder |
const Moses::FactorMask & | m_inputFactorUsed |
std::ostream * | m_outputSearchGraphStream |
std::ostream * | m_detailedTranslationReportingStream |
std::ostream * | m_alignmentInfoStream |
std::string | m_inputFilePath |
std::istream * | m_inputStream |
Moses::OutputCollector * | m_detailOutputCollector |
Moses::OutputCollector * | m_nBestOutputCollector |
Moses::OutputCollector * | m_searchGraphOutputCollector |
Moses::OutputCollector * | m_singleBestOutputCollector |
Moses::OutputCollector * | m_alignmentInfoCollector |
Definition at line 61 of file IOWrapper.h.
typedef std::set< std::pair<size_t, size_t> > MosesChartCmd::IOWrapper::Alignments [protected] |
Definition at line 82 of file IOWrapper.h.
typedef std::vector<std::pair<Moses::Word, Moses::WordsRange> > MosesChartCmd::IOWrapper::ApplicationContext [protected] |
Definition at line 64 of file IOWrapper.h.
MosesChartCmd::IOWrapper::IOWrapper | ( | const std::vector< Moses::FactorType > & | inputFactorOrder, | |
const std::vector< Moses::FactorType > & | outputFactorOrder, | |||
const Moses::FactorMask & | inputFactorUsed, | |||
size_t | nBestSize, | |||
const std::string & | nBestFilePath, | |||
const std::string & | inputFilePath = "" | |||
) |
MosesChartCmd::IOWrapper::~IOWrapper | ( | ) |
Definition at line 126 of file IOWrapper.cpp.
References m_alignmentInfoCollector, m_alignmentInfoStream, m_detailedTranslationReportingStream, m_detailOutputCollector, m_inputFilePath, m_inputStream, m_nBestOutputCollector, m_outputSearchGraphStream, m_searchGraphOutputCollector, and m_singleBestOutputCollector.
void MosesChartCmd::IOWrapper::Backtrack | ( | const Moses::ChartHypothesis * | hypo | ) |
Definition at line 204 of file IOWrapper.cpp.
References Moses::ChartHypothesis::GetId(), Moses::ChartHypothesis::GetPrevHypos(), and VERBOSE.
Referenced by OutputBestHypo().
void MosesChartCmd::IOWrapper::FixPrecision | ( | std::ostream & | stream, | |
size_t | size = 3 | |||
) | [static] |
Definition at line 560 of file IOWrapper.cpp.
Referenced by OutputBestHypo(), and OutputNBestList().
InputType * MosesChartCmd::IOWrapper::GetInput | ( | Moses::InputType * | inputType | ) |
Definition at line 146 of file IOWrapper.cpp.
References Moses::InputType::GetTranslationId(), m_inputFactorOrder, m_inputStream, m_translationId, NULL, Moses::InputType::Read(), and Moses::InputType::SetTranslationId().
Referenced by ReadInput().
Moses::OutputCollector* MosesChartCmd::IOWrapper::GetSearchGraphOutputCollector | ( | ) | [inline] |
Definition at line 121 of file IOWrapper.h.
References m_searchGraphOutputCollector.
Referenced by TranslationTask::Run().
void MosesChartCmd::IOWrapper::OutputAlignment | ( | size_t | translationId, | |
const Moses::ChartHypothesis * | hypo | |||
) |
Definition at line 666 of file IOWrapper.cpp.
References m_alignmentInfoCollector, OutputAlignment(), and Moses::OutputCollector::Write().
void MosesChartCmd::IOWrapper::OutputAlignment | ( | std::vector< std::set< size_t > > & | retAlignmentsS2T, | |
const Moses::AlignmentInfo & | ai | |||
) | [protected] |
size_t MosesChartCmd::IOWrapper::OutputAlignment | ( | Alignments & | retAlign, | |
const Moses::ChartHypothesis * | hypo, | |||
size_t | startTarget | |||
) | [protected] |
Definition at line 686 of file IOWrapper.cpp.
References Moses::AlignmentInfo::begin(), MosesChartCmd::CalcSourceSize(), CHECK, Moses::AlignmentInfo::end(), Moses::TargetPhrase::GetAlignNonTerm(), Moses::TargetPhrase::GetAlignTerm(), Moses::ChartHypothesis::GetCurrSourceRange(), Moses::ChartHypothesis::GetCurrTargetPhrase(), Moses::AlignmentInfo::GetNonTermIndexMap(), Moses::WordsRange::GetNumWordsCovered(), Moses::ChartHypothesis::GetPrevHypos(), Moses::Phrase::GetSize(), Moses::AlignmentInfo::GetSourceIndex2PosMap(), Moses::WordsRange::GetStartPos(), Moses::Phrase::GetWord(), Moses::Word::IsNonTerminal(), and MosesChartCmd::ShiftOffsets().
Referenced by OutputAlignment(), and TranslationTask::Run().
size_t MosesChartCmd::IOWrapper::OutputAlignmentNBest | ( | Alignments & | retAlign, | |
const Moses::ChartTrellisNode & | node, | |||
size_t | startTarget | |||
) | [protected] |
Definition at line 591 of file IOWrapper.cpp.
References Moses::AlignmentInfo::begin(), MosesChartCmd::CalcSourceSize(), CHECK, Moses::AlignmentInfo::end(), Moses::TargetPhrase::GetAlignNonTerm(), Moses::TargetPhrase::GetAlignTerm(), Moses::ChartTrellisNode::GetChildren(), Moses::ChartHypothesis::GetCurrSourceRange(), Moses::ChartHypothesis::GetCurrTargetPhrase(), Moses::ChartTrellisNode::GetHypothesis(), Moses::AlignmentInfo::GetNonTermIndexMap(), Moses::WordsRange::GetNumWordsCovered(), Moses::Phrase::GetSize(), Moses::AlignmentInfo::GetSourceIndex2PosMap(), Moses::WordsRange::GetStartPos(), Moses::Phrase::GetWord(), Moses::Word::IsNonTerminal(), and MosesChartCmd::ShiftOffsets().
Referenced by OutputNBestList().
void MosesChartCmd::IOWrapper::OutputAllFeatureScores | ( | const Moses::ScoreComponentCollection & | features, | |
std::ostream & | out | |||
) | [protected] |
Definition at line 404 of file IOWrapper.cpp.
References Moses::FeatureFunction::GetScoreProducerDescription(), Moses::FeatureFunction::IsTuneable(), and OutputFeatureScores().
Referenced by OutputNBestList().
void MosesChartCmd::IOWrapper::OutputBestHypo | ( | const std::vector< const Moses::Factor * > & | mbrBestHypo, | |
long | translationId | |||
) |
void MosesChartCmd::IOWrapper::OutputBestHypo | ( | search::Applied | applied, | |
long | translationId | |||
) |
Definition at line 375 of file IOWrapper.cpp.
References CHECK, FixPrecision(), search::Header::GetScore(), Moses::Phrase::GetSize(), Moses::Phrase::GetStringRep(), m_singleBestOutputCollector, Moses::Phrase::RemoveWord(), Moses::Incremental::ToPhrase(), and Moses::OutputCollector::Write().
void MosesChartCmd::IOWrapper::OutputBestHypo | ( | const Moses::ChartHypothesis * | hypo, | |
long | translationId | |||
) |
Definition at line 333 of file IOWrapper.cpp.
References Moses::ARRAY_SIZE_INCR, Backtrack(), CHECK, Moses::ChartHypothesis::CreateOutputPhrase(), FixPrecision(), Moses::Phrase::GetSize(), Moses::Phrase::GetStringRep(), Moses::ChartHypothesis::GetTotalScore(), m_singleBestOutputCollector, NULL, Moses::Phrase::RemoveWord(), VERBOSE, and Moses::OutputCollector::Write().
Referenced by TranslationTask::Run().
void MosesChartCmd::IOWrapper::OutputBestNone | ( | long | translationId | ) |
Definition at line 394 of file IOWrapper.cpp.
References m_singleBestOutputCollector, and Moses::OutputCollector::Write().
Referenced by TranslationTask::Run().
void MosesChartCmd::IOWrapper::OutputDetailedTranslationReport | ( | const Moses::ChartHypothesis * | hypo, | |
const Moses::Sentence & | sentence, | |||
long | translationId | |||
) |
Definition at line 316 of file IOWrapper.cpp.
References CHECK, m_detailOutputCollector, NULL, OutputTranslationOptions(), and Moses::OutputCollector::Write().
Referenced by TranslationTask::Run().
void MosesChartCmd::IOWrapper::OutputFeatureScores | ( | std::ostream & | out, | |
const Moses::ScoreComponentCollection & | features, | |||
const Moses::FeatureFunction * | ff, | |||
std::string & | lastName | |||
) | [protected] |
Definition at line 424 of file IOWrapper.cpp.
References Moses::FVector::cbegin(), Moses::FVector::cend(), Moses::FeatureFunction::GetNumScoreComponents(), Moses::FeatureFunction::GetScoreProducerDescription(), Moses::ScoreComponentCollection::GetScoresForProducer(), Moses::ScoreComponentCollection::GetVectorForProducer(), and Moses::StaticData::IsLabeledNBestList().
Referenced by OutputAllFeatureScores().
void MosesChartCmd::IOWrapper::OutputNBestList | ( | const std::vector< search::Applied > & | nbest, | |
long | translationId | |||
) |
Definition at line 534 of file IOWrapper.cpp.
References CHECK, FixPrecision(), Moses::Phrase::GetSize(), m_nBestOutputCollector, m_outputFactorOrder, OutputAllFeatureScores(), Moses::OutputCollector::OutputIsCout(), MosesChartCmd::OutputSurface(), Moses::Incremental::PhraseAndFeatures(), Moses::Phrase::RemoveWord(), and Moses::OutputCollector::Write().
void MosesChartCmd::IOWrapper::OutputNBestList | ( | const Moses::ChartTrellisPathList & | nBestList, | |
long | translationId | |||
) |
Definition at line 448 of file IOWrapper.cpp.
References Moses::ChartTrellisPathList::begin(), CHECK, Moses::ChartTrellisPathList::end(), FixPrecision(), Moses::ChartTrellisPath::GetFinalNode(), Moses::ChartTrellisPath::GetOutputPhrase(), Moses::ChartTrellisPath::GetScoreBreakdown(), Moses::Phrase::GetSize(), Moses::ChartTrellisPath::GetTotalScore(), m_nBestOutputCollector, m_outputFactorOrder, OutputAlignmentNBest(), OutputAllFeatureScores(), Moses::OutputCollector::OutputIsCout(), MosesChartCmd::OutputSurface(), Moses::Phrase::RemoveWord(), and Moses::OutputCollector::Write().
Referenced by TranslationTask::Run().
void MosesChartCmd::IOWrapper::OutputTranslationOptions | ( | std::ostream & | out, | |
ApplicationContext & | applicationContext, | |||
const Moses::ChartHypothesis * | hypo, | |||
const Moses::Sentence & | sentence, | |||
long | translationId | |||
) | [protected] |
Definition at line 293 of file IOWrapper.cpp.
References Moses::ChartHypothesis::GetCurrSourceRange(), Moses::ChartHypothesis::GetCurrTargetPhrase(), Moses::ChartHypothesis::GetPrevHypos(), Moses::ChartHypothesis::GetScoreBreakdown(), Moses::TargetPhrase::GetTargetLHS(), Moses::ChartHypothesis::GetTotalScore(), NULL, ReconstructApplicationContext(), and WriteApplicationContext().
Referenced by OutputDetailedTranslationReport().
void MosesChartCmd::IOWrapper::ReconstructApplicationContext | ( | const Moses::ChartHypothesis & | hypo, | |
const Moses::Sentence & | sentence, | |||
ApplicationContext & | context | |||
) | [protected] |
Definition at line 248 of file IOWrapper.cpp.
References end, Moses::ChartHypothesis::GetCurrSourceRange(), Moses::WordsRange::GetEndPos(), Moses::ChartHypothesis::GetPrevHypos(), Moses::WordsRange::GetStartPos(), and Moses::Sentence::GetWord().
Referenced by OutputTranslationOptions().
void MosesChartCmd::IOWrapper::ResetTranslationId | ( | ) |
Definition at line 141 of file IOWrapper.cpp.
References m_translationId.
Referenced by GetIOWrapper().
void MosesChartCmd::IOWrapper::WriteApplicationContext | ( | std::ostream & | out, | |
const ApplicationContext & | context | |||
) | [protected] |
Definition at line 279 of file IOWrapper.cpp.
Referenced by OutputTranslationOptions().
std::ostream* MosesChartCmd::IOWrapper::m_alignmentInfoStream [protected] |
std::ostream* MosesChartCmd::IOWrapper::m_detailedTranslationReportingStream [protected] |
Definition at line 76 of file IOWrapper.h.
Referenced by OutputDetailedTranslationReport(), and ~IOWrapper().
const std::vector<Moses::FactorType>& MosesChartCmd::IOWrapper::m_inputFactorOrder [protected] |
const Moses::FactorMask& MosesChartCmd::IOWrapper::m_inputFactorUsed [protected] |
Definition at line 70 of file IOWrapper.h.
std::string MosesChartCmd::IOWrapper::m_inputFilePath [protected] |
std::istream* MosesChartCmd::IOWrapper::m_inputStream [protected] |
const std::vector<Moses::FactorType>& MosesChartCmd::IOWrapper::m_outputFactorOrder [protected] |
std::ostream* MosesChartCmd::IOWrapper::m_outputSearchGraphStream [protected] |
Definition at line 78 of file IOWrapper.h.
Referenced by GetSearchGraphOutputCollector(), and ~IOWrapper().
Definition at line 79 of file IOWrapper.h.
Referenced by OutputBestHypo(), OutputBestNone(), and ~IOWrapper().
long MosesChartCmd::IOWrapper::m_translationId [protected] |