From f6f9044556c2c3531712f55ad7179d0600f12347 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Thu, 12 Sep 2019 13:35:40 +0200 Subject: [PATCH] Deleted argument headMvt from setInfos --- decoder/src/Decoder.cpp | 2 +- trainer/src/Trainer.cpp | 8 ++++---- transition_machine/include/Action.hpp | 5 +---- transition_machine/src/Action.cpp | 17 +---------------- 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/decoder/src/Decoder.cpp b/decoder/src/Decoder.cpp index f27bd8f..3218009 100644 --- a/decoder/src/Decoder.cpp +++ b/decoder/src/Decoder.cpp @@ -180,7 +180,7 @@ void applyActionAndTakeTransition(TransitionMachine & tm, const std::string & ac { Action * action = tm.getCurrentClassifier()->getAction(actionName); TransitionMachine::Transition * transition = tm.getTransition(actionName); - action->setInfos(transition->headMvt, tm.getCurrentClassifier()->name); + action->setInfos(tm.getCurrentClassifier()->name); config.addToActionsHistory(tm.getCurrentClassifier()->name, actionName, 0); action->apply(config); tm.takeTransition(transition); diff --git a/trainer/src/Trainer.cpp b/trainer/src/Trainer.cpp index 6e90684..56a2a49 100644 --- a/trainer/src/Trainer.cpp +++ b/trainer/src/Trainer.cpp @@ -75,7 +75,7 @@ void Trainer::computeScoreOnDev() std::string neededActionName = tm.getCurrentClassifier()->getActionName(neededActionIndex); Action * action = tm.getCurrentClassifier()->getAction(neededActionName); TransitionMachine::Transition * transition = tm.getTransition(neededActionName); - action->setInfos(transition->headMvt, tm.getCurrentClassifier()->name); + action->setInfos(tm.getCurrentClassifier()->name); action->apply(*devConfig); tm.takeTransition(transition); @@ -134,7 +134,7 @@ void Trainer::computeScoreOnDev() } TransitionMachine::Transition * transition = tm.getTransition(actionName); - action->setInfos(transition->headMvt, tm.getCurrentClassifier()->name); + action->setInfos(tm.getCurrentClassifier()->name); devConfig->addToActionsHistory(tm.getCurrentClassifier()->name, actionName, tm.getCurrentClassifier()->getActionCost(*devConfig, actionName)); action->apply(*devConfig); @@ -210,7 +210,7 @@ void Trainer::doStepNoTrain() Action * action = tm.getCurrentClassifier()->getAction(neededActionName); TransitionMachine::Transition * transition = tm.getTransition(neededActionName); - action->setInfos(transition->headMvt, tm.getCurrentClassifier()->name); + action->setInfos(tm.getCurrentClassifier()->name); trainConfig.addToActionsHistory(tm.getCurrentClassifier()->name, action->name, tm.getCurrentClassifier()->getActionCost(trainConfig, action->name)); action->apply(trainConfig); @@ -464,7 +464,7 @@ void Trainer::doStepTrain() Action * action = tm.getCurrentClassifier()->getAction(actionName); TransitionMachine::Transition * transition = tm.getTransition(actionName); - action->setInfos(transition->headMvt, tm.getCurrentClassifier()->name); + action->setInfos(tm.getCurrentClassifier()->name); trainConfig.addToActionsHistory(tm.getCurrentClassifier()->name, actionName, tm.getCurrentClassifier()->getActionCost(trainConfig, actionName)); diff --git a/transition_machine/include/Action.hpp b/transition_machine/include/Action.hpp index 322c7f6..9b8cc2f 100644 --- a/transition_machine/include/Action.hpp +++ b/transition_machine/include/Action.hpp @@ -66,8 +66,6 @@ class Action /// This is useful to maintain a history of past actions, keeping only the type of the actions. std::string namePrefix; - /// @brief The movement of the machine's head associated with this action. - int headMovement; /// @brief The name of the machine's current state when this action was performed. std::string stateName; @@ -109,9 +107,8 @@ class Action /// /// These informations will be usefull when undoing the Action. /// - /// @param headMovement The movement of the machine's head associated with this action. /// @param stateName The name of the machine's current state when this action was performed. - void setInfos(int headMovement, std::string stateName); + void setInfos(std::string stateName); }; #endif diff --git a/transition_machine/src/Action.cpp b/transition_machine/src/Action.cpp index 85a6cda..d647cee 100644 --- a/transition_machine/src/Action.cpp +++ b/transition_machine/src/Action.cpp @@ -18,8 +18,6 @@ void Action::apply(Config & config) config.getCurrentStateHistory().push(name); config.pastActions.push(std::pair<std::string, Action>(config.getCurrentStateName(), *this)); - - config.moveHead(headMovement); } bool Action::appliable(Config & config) @@ -33,12 +31,6 @@ bool Action::appliable(Config & config) void Action::undo(Config & config) { - if (ProgramParameters::debug) - fprintf(stderr, "Head = %d, will move back of %d\n", config.getHead(), headMovement); - config.moveHead(-headMovement); - if (ProgramParameters::debug) - fprintf(stderr, "Head = %d\n", config.getHead()); - for(int i = sequence.size()-1; i >= 0; i--) sequence[i].undo(config, sequence[i]); @@ -77,12 +69,6 @@ void Action::undo(Config & config) void Action::undoOnlyStack(Config & config) { - if (ProgramParameters::debug) - fprintf(stderr, "Head = %d, will move back of %d\n", config.getHead(), headMovement); - config.moveHead(-headMovement); - if (ProgramParameters::debug) - fprintf(stderr, "Head = %d\n", config.getHead()); - for(int i = sequence.size()-1; i >= 0; i--) { auto type = sequence[i].type; @@ -141,9 +127,8 @@ void Action::printForDebug(FILE * output) fprintf(output, "\n"); } -void Action::setInfos(int headMovement, std::string stateName) +void Action::setInfos(std::string stateName) { - this->headMovement = headMovement; this->stateName = stateName; } -- GitLab