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

Added debug info

parent dd30d41d
Branches
No related tags found
No related merge requests found
...@@ -175,7 +175,7 @@ void applyActionAndTakeTransition(TransitionMachine & tm, const std::string & ac ...@@ -175,7 +175,7 @@ void applyActionAndTakeTransition(TransitionMachine & tm, const std::string & ac
Action * action = tm.getCurrentClassifier()->getAction(actionName); Action * action = tm.getCurrentClassifier()->getAction(actionName);
TransitionMachine::Transition * transition = tm.getTransition(actionName); TransitionMachine::Transition * transition = tm.getTransition(actionName);
action->setInfos(transition->headMvt, tm.getCurrentState()); action->setInfos(transition->headMvt, tm.getCurrentState());
config.addToActionsHistory(config.getCurrentStateName(), actionName, tm.getCurrentClassifier()->getActionCost(config, actionName)); config.addToActionsHistory(config.getCurrentStateName(), actionName, 0);
action->apply(config); action->apply(config);
tm.takeTransition(transition); tm.takeTransition(transition);
} }
......
...@@ -377,8 +377,12 @@ void Oracle::createDatabase() ...@@ -377,8 +377,12 @@ void Oracle::createDatabase()
int head = c.getHead(); int head = c.getHead();
int stackHead = c.stackEmpty() ? 0 : c.stackTop(); int stackHead = c.stackEmpty() ? 0 : c.stackTop();
int stackGov = stackHead + std::stoi(govs.getRef(stackHead-head)); int stackGov = 0;
int headGov = head + std::stoi(govs.getRef(0)); try {stackGov = stackHead + std::stoi(govs.getRef(stackHead-head));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
int headGov = 0;
try {headGov = head + std::stoi(govs.getRef(0));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
int sentenceStart = c.getHead()-1 < 0 ? 0 : c.getHead()-1; int sentenceStart = c.getHead()-1 < 0 ? 0 : c.getHead()-1;
int sentenceEnd = c.getHead(); int sentenceEnd = c.getHead();
...@@ -405,7 +409,9 @@ void Oracle::createDatabase() ...@@ -405,7 +409,9 @@ void Oracle::createDatabase()
exit(1); exit(1);
} }
int otherGov = i + std::stoi(govs.getRef(i-head)); int otherGov = 0;
try {otherGov = i + std::stoi(govs.getRef(i-head));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
for (int j = 0; j < c.stackSize(); j++) for (int j = 0; j < c.stackSize(); j++)
{ {
...@@ -443,7 +449,9 @@ void Oracle::createDatabase() ...@@ -443,7 +449,9 @@ void Oracle::createDatabase()
{ {
for (int i = head; i <= sentenceEnd; i++) for (int i = head; i <= sentenceEnd; i++)
{ {
int otherGov = i + std::stoi(govs.getRef(i-head)); int otherGov = 0;
try {otherGov = i + std::stoi(govs.getRef(i-head));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
if (otherGov == stackHead) if (otherGov == stackHead)
cost++; cost++;
} }
...@@ -457,7 +465,9 @@ void Oracle::createDatabase() ...@@ -457,7 +465,9 @@ void Oracle::createDatabase()
for (int i = head+1; i <= sentenceEnd; i++) for (int i = head+1; i <= sentenceEnd; i++)
{ {
int otherGov = i + std::stoi(govs.getRef(i-head)); int otherGov = 0;
try {otherGov = i + std::stoi(govs.getRef(i-head));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
if (otherGov == stackHead || stackGov == i) if (otherGov == stackHead || stackGov == i)
cost++; cost++;
} }
...@@ -476,7 +486,9 @@ void Oracle::createDatabase() ...@@ -476,7 +486,9 @@ void Oracle::createDatabase()
if (s == c.stackTop()) if (s == c.stackTop())
continue; continue;
int otherGov = s + std::stoi(govs.getRef(s-head)); int otherGov = 0;
try {otherGov = s + std::stoi(govs.getRef(s-head));}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
if (otherGov == head || headGov == s) if (otherGov == head || headGov == s)
cost++; cost++;
} }
...@@ -551,12 +563,16 @@ void Oracle::explainCostOfAction(FILE * output, Config & c, const std::string & ...@@ -551,12 +563,16 @@ void Oracle::explainCostOfAction(FILE * output, Config & c, const std::string &
if (object[0] == "b") if (object[0] == "b")
{ {
int index = c.getHead() + std::stoi(object[1]); int index = 0;
try {index = c.getHead() + std::stoi(object[1]);}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
expected = c.getTape(tape).getRef(index-c.getHead()); expected = c.getTape(tape).getRef(index-c.getHead());
} }
else if (object[0] == "s") else if (object[0] == "s")
{ {
int stackIndex = std::stoi(object[1]); int stackIndex = 0;
try {stackIndex = std::stoi(object[1]);}
catch (std::exception &){fprintf(stderr, "ERROR (%s) : aborting.\n", ERRINFO); exit(1);}
int bufferIndex = c.stackGetElem(stackIndex) + c.getHead(); int bufferIndex = c.stackGetElem(stackIndex) + c.getHead();
expected = c.getTape(tape).getRef(bufferIndex-c.getHead()); expected = c.getTape(tape).getRef(bufferIndex-c.getHead());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment