From 28d34359ee5f4e343d50bc54b2f128534a0c09ec Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Mon, 15 Jul 2019 11:28:43 +0200 Subject: [PATCH] Added a way to have step by step output --- decoder/src/macaon_decode.cpp | 2 ++ maca_common/include/ProgramParameters.hpp | 1 + maca_common/src/ProgramOutput.cpp | 10 ++++++++++ maca_common/src/ProgramParameters.cpp | 2 ++ 4 files changed, 15 insertions(+) diff --git a/decoder/src/macaon_decode.cpp b/decoder/src/macaon_decode.cpp index 6bb6bfc..a253cc0 100644 --- a/decoder/src/macaon_decode.cpp +++ b/decoder/src/macaon_decode.cpp @@ -37,6 +37,7 @@ po::options_description getOptionsDescription() opt.add_options() ("help,h", "Produce this help message") ("debug,d", "Print infos on stderr") + ("delayedOutput", "Print the output only at the end") ("showActions", "Print actions predicted by each classifier") ("dicts", po::value<std::string>()->default_value(""), "The .dict file describing all the dictionaries to be used in the experiement. By default the filename specified in the .tm file will be used") @@ -140,6 +141,7 @@ int main(int argc, char * argv[]) ProgramParameters::input = vm["input"].as<std::string>(); ProgramParameters::mcdName = vm["mcd"].as<std::string>(); ProgramParameters::debug = vm.count("debug") == 0 ? false : true; + ProgramParameters::delayedOutput = vm.count("delayedOutput") == 0 ? false : true; ProgramParameters::showActions = vm.count("showActions") == 0 ? false : true; ProgramParameters::interactive = vm["interactive"].as<bool>(); ProgramParameters::errorAnalysis = vm.count("errorAnalysis") == 0 ? false : true; diff --git a/maca_common/include/ProgramParameters.hpp b/maca_common/include/ProgramParameters.hpp index f10dfb3..8d6df77 100644 --- a/maca_common/include/ProgramParameters.hpp +++ b/maca_common/include/ProgramParameters.hpp @@ -78,6 +78,7 @@ struct ProgramParameters static bool alwaysSave; static bool noNeuralNetwork; static bool showActions; + static bool delayedOutput; private : diff --git a/maca_common/src/ProgramOutput.cpp b/maca_common/src/ProgramOutput.cpp index 40a2102..e9bde67 100644 --- a/maca_common/src/ProgramOutput.cpp +++ b/maca_common/src/ProgramOutput.cpp @@ -6,6 +6,8 @@ ProgramOutput ProgramOutput::instance; void ProgramOutput::print(FILE * output) { + if (!ProgramParameters::delayedOutput) + return; for (auto & line : matrix) for (unsigned int i = 0; i < line.size(); i++) fprintf(output, "%s%s%s", ProgramParameters::printOutputEntropy ? ("<"+float2str(line[i].second,"%f")+">").c_str() : "", line[i].first.c_str(), i == line.size()-1 ? "\n" : "\t"); @@ -13,6 +15,14 @@ void ProgramOutput::print(FILE * output) void ProgramOutput::addLine(const std::vector< std::pair<std::string, float> > & line, unsigned int index) { + if (!ProgramParameters::delayedOutput) + { + for (unsigned int i = 0; i < line.size(); i++) + fprintf(stdout, "%s%s", line[i].first.c_str(), i == line.size()-1 ? "\n" : "\t"); + + return; + } + while (matrix.size() < index+1) matrix.emplace_back(); diff --git a/maca_common/src/ProgramParameters.cpp b/maca_common/src/ProgramParameters.cpp index 7eea51d..e1a8721 100644 --- a/maca_common/src/ProgramParameters.cpp +++ b/maca_common/src/ProgramParameters.cpp @@ -72,3 +72,5 @@ float ProgramParameters::randomDebugProbability; bool ProgramParameters::alwaysSave; bool ProgramParameters::noNeuralNetwork; bool ProgramParameters::showActions; +bool ProgramParameters::delayedOutput; + -- GitLab