Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2015-12-11 20:29:10 +0300
committerHieu Hoang <hieuhoang@gmail.com>2015-12-11 20:29:10 +0300
commite5d3306519a43dc02a85cbf2e8e67e3699bf91b8 (patch)
treea8dfaa1bf86781df1c06e624a967dba9301166d4 /moses/ChartManager.cpp
parent51d21b09c0c59b2449cce2ba2f524cd3dc5ff9b1 (diff)
parent40ed3df9cb513681569a2fcde32a5215c38253f3 (diff)
Merge ../mosesdecoder into perf_moses2
Diffstat (limited to 'moses/ChartManager.cpp')
-rw-r--r--moses/ChartManager.cpp56
1 files changed, 19 insertions, 37 deletions
diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp
index 082f3f05e..d83bc3a7d 100644
--- a/moses/ChartManager.cpp
+++ b/moses/ChartManager.cpp
@@ -128,16 +128,15 @@ void ChartManager::Decode()
*/
void ChartManager::AddXmlChartOptions()
{
- // const StaticData &staticData = StaticData::Instance();
-
- const std::vector <ChartTranslationOptions*> xmlChartOptionsList = m_source.GetXmlChartTranslationOptions();
+ const std::vector <ChartTranslationOptions*> xmlChartOptionsList
+ = m_source.GetXmlChartTranslationOptions();
IFVERBOSE(2) {
cerr << "AddXmlChartOptions " << xmlChartOptionsList.size() << endl;
}
if (xmlChartOptionsList.size() == 0) return;
- for(std::vector<ChartTranslationOptions*>::const_iterator i = xmlChartOptionsList.begin();
- i != xmlChartOptionsList.end(); ++i) {
+ typedef std::vector<ChartTranslationOptions*>::const_iterator citer;
+ for(citer i = xmlChartOptionsList.begin(); i != xmlChartOptionsList.end(); ++i) {
ChartTranslationOptions* opt = *i;
const Range &range = opt->GetSourceWordsRange();
@@ -204,8 +203,7 @@ void ChartManager::CalcNBest(
// than n. The n-best factor determines how much bigger the limit should be,
// with 0 being 'unlimited.' This actually sets a large-ish limit in case
// too many translations are identical.
- const StaticData &staticData = StaticData::Instance();
- const std::size_t nBestFactor = staticData.options().nbest.factor;
+ const std::size_t nBestFactor = options()->nbest.factor;
std::size_t numDerivations = (nBestFactor == 0) ? n*1000 : n*nBestFactor;
// Extract the derivations.
@@ -315,15 +313,14 @@ void ChartManager::OutputBest(OutputCollector *collector) const
void ChartManager::OutputNBest(OutputCollector *collector) const
{
- // const StaticData &staticData = StaticData::Instance();
- size_t nBestSize = options().nbest.nbest_size;
+ size_t nBestSize = options()->nbest.nbest_size;
if (nBestSize > 0) {
const size_t translationId = m_source.GetTranslationId();
VERBOSE(2,"WRITING " << nBestSize << " TRANSLATION ALTERNATIVES TO "
- << options().nbest.output_file_path << endl);
+ << options()->nbest.output_file_path << endl);
std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList;
- CalcNBest(nBestSize, nBestList, options().nbest.only_distinct);
+ CalcNBest(nBestSize, nBestList, options()->nbest.only_distinct);
OutputNBestList(collector, nBestList, translationId);
IFVERBOSE(2) {
PrintUserTime("N-Best Hypotheses Generation Time:");
@@ -336,9 +333,6 @@ void ChartManager::OutputNBestList(OutputCollector *collector,
const ChartKBestExtractor::KBestVec &nBestList,
long translationId) const
{
- // const StaticData &staticData = StaticData::Instance();
- // const std::vector<Moses::FactorType> &outputFactorOrder = staticData.GetOutputFactorOrder();
-
std::ostringstream out;
if (collector->OutputIsCout()) {
@@ -347,7 +341,7 @@ void ChartManager::OutputNBestList(OutputCollector *collector,
FixPrecision(out);
}
- NBestOptions const& nbo = options().nbest;
+ NBestOptions const& nbo = options()->nbest;
bool includeWordAlignment = nbo.include_alignment_info;
bool PrintNBestTrees = nbo.print_trees;
@@ -369,7 +363,7 @@ void ChartManager::OutputNBestList(OutputCollector *collector,
OutputSurface(out, outputPhrase); // , outputFactorOrder, false);
out << " ||| ";
boost::shared_ptr<ScoreComponentCollection> scoreBreakdown = ChartKBestExtractor::GetOutputScoreBreakdown(derivation);
- bool with_labels = options().nbest.include_feature_labels;
+ bool with_labels = options()->nbest.include_feature_labels;
scoreBreakdown->OutputAllFeatureScores(out, with_labels);
out << " ||| " << derivation.score;
@@ -615,13 +609,11 @@ void ChartManager::OutputDetailedTranslationReport(
collector->Write(translationId, out.str());
//DIMw
- const StaticData &staticData = StaticData::Instance();
-
- if (options().output.detailed_all_transrep_filepath.size()) {
+ if (options()->output.detailed_all_transrep_filepath.size()) {
const Sentence &sentence = static_cast<const Sentence &>(m_source);
- size_t nBestSize = staticData.options().nbest.nbest_size;
+ size_t nBestSize = options()->nbest.nbest_size;
std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList;
- CalcNBest(nBestSize, nBestList, staticData.options().nbest.nbest_size);
+ CalcNBest(nBestSize, nBestList, options()->nbest.only_distinct);
OutputDetailedAllTranslationReport(collector, nBestList, sentence, translationId);
}
@@ -725,7 +717,8 @@ void ChartManager::OutputDetailedTreeFragmentsTranslationReport(OutputCollector
OutputTreeFragmentsTranslationOptions(out, applicationContext, hypo, sentence, translationId);
//Tree of full sentence
- const StatefulFeatureFunction* treeStructure = StaticData::Instance().GetTreeStructure();
+ const StatefulFeatureFunction* treeStructure;
+ treeStructure = StaticData::Instance().GetTreeStructure();
if (treeStructure != NULL) {
const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
for( size_t i=0; i<sff.size(); i++ ) {
@@ -813,15 +806,6 @@ void ChartManager::OutputDetailedAllTranslationReport(
collector->Write(translationId, out.str());
}
-// void ChartManager::OutputSearchGraphHypergraph() const
-// {
-// const StaticData &staticData = StaticData::Instance();
-// if (staticData.GetOutputSearchGraphHypergraph()) {
-// HypergraphOutput<ChartManager> hypergraphOutputChart(PRECISION);
-// hypergraphOutputChart.Write(*this);
-// }
-// }
-
void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothesis *hypo, long translationId) const
{
if (!collector)
@@ -834,11 +818,11 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe
Backtrack(hypo);
VERBOSE(3,"0" << std::endl);
- if (options().output.ReportHypoScore) {
+ if (options()->output.ReportHypoScore) {
out << hypo->GetFutureScore() << " ";
}
- if (options().output.RecoverPath) {
+ if (options()->output.RecoverPath) {
out << "||| ";
}
Phrase outPhrase(ARRAY_SIZE_INCR);
@@ -851,14 +835,12 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe
outPhrase.RemoveWord(0);
outPhrase.RemoveWord(outPhrase.GetSize() - 1);
- const std::vector<FactorType> outputFactorOrder
- = StaticData::Instance().GetOutputFactorOrder();
- string output = outPhrase.GetStringRep(outputFactorOrder);
+ string output = outPhrase.GetStringRep(options()->output.factor_order);
out << output << endl;
} else {
VERBOSE(1, "NO BEST TRANSLATION" << endl);
- if (options().output.ReportHypoScore) {
+ if (options()->output.ReportHypoScore) {
out << "0 ";
}