Skip to content
Snippets Groups Projects
Commit 3fe310a0 authored by Franck Dary's avatar Franck Dary
Browse files

Added a new option -d for debug output

parent 4e8d74f4
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,8 @@ class Decoder
BD & bd;
/// @brief The current configuration of the TransitionMachine
Config & config;
/// @brief is true, decode will print infos on stderr
bool debugMode;
public :
......@@ -31,7 +33,7 @@ class Decoder
/// @param tm The trained TransitionMachine
/// @param bd The BD we need to fill
/// @param config The current configuration of the TransitionMachine
Decoder(TransitionMachine & tm, BD & bd, Config & config);
Decoder(TransitionMachine & tm, BD & bd, Config & config, bool debugMode);
/// @brief Fill bd using tm.
void decode();
};
......
#include "Decoder.hpp"
#include "util.hpp"
Decoder::Decoder(TransitionMachine & tm, BD & bd, Config & config)
Decoder::Decoder(TransitionMachine & tm, BD & bd, Config & config, bool debugMode)
: tm(tm), bd(bd), config(config)
{
this->debugMode = debugMode;
}
void Decoder::decode()
......@@ -15,12 +16,17 @@ void Decoder::decode()
config.setCurrentStateName(&currentState->name);
Dict::currentClassifierName = classifier->name;
//config.printForDebug(stderr);
//fprintf(stderr, "State : \'%s\'\n", currentState->name.c_str());
if (debugMode)
{
config.printForDebug(stderr);
fprintf(stderr, "State : \'%s\'\n", currentState->name.c_str());
}
auto weightedActions = classifier->weightActions(config);
//Classifier::printWeightedActions(stderr, weightedActions);
if (debugMode)
Classifier::printWeightedActions(stderr, weightedActions);
std::string & predictedAction = weightedActions[0].second.second;
Action * action = classifier->getAction(predictedAction);
......
......@@ -36,6 +36,7 @@ po::options_description getOptionsDescription()
po::options_description opt("Optional");
opt.add_options()
("help,h", "Produce this help message")
("debug,d", "Print infos on stderr")
("lang", po::value<std::string>()->default_value("fr"),
"Language you are working with");
......@@ -103,6 +104,15 @@ int main(int argc, char * argv[])
const char * MACAON_DIR = std::getenv("MACAON_DIR");
std::string slash = "/";
std::string expPath = MACAON_DIR + slash + lang + slash + "bin/" + expName + slash;
bool debugMode = vm.count("debug") == 0 ? false : true;
if(debugMode)
{
fprintf(stderr, "Oui\n");
}
else
{
fprintf(stderr, "Non\n");
}
tmFilename = expPath + tmFilename;
bdFilename = expPath + bdFilename;
......@@ -113,7 +123,7 @@ int main(int argc, char * argv[])
Config config(bd, expPath);
config.readInput(inputFilename);
Decoder decoder(tapeMachine, bd, config);
Decoder decoder(tapeMachine, bd, config, debugMode);
decoder.decode();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment