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

Corrected a bug where bad rules were falsely judged as appliable

parent d30277ec
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,7 @@ if(NOT CMAKE_BUILD_TYPE)
endif()
set(CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "-g3")
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -Ofast")
set(CMAKE_CXX_FLAGS_RELEASE "-Ofast")
include_directories(maca_common/include)
......
......@@ -250,7 +250,10 @@ bool ruleIsAppliable(const std::string & Ufrom, const std::string & rule)
if(rule[sepIndex] == '@')
break;
unsigned int suffixLength = sepIndex - 1;
int suffixLength = sepIndex - 1;
if (suffixLength > (int)Ufrom.size())
return false;
for(unsigned int j = 1, i = from.size() - suffixLength; j < sepIndex; i++, j++)
if((rule[j] != '*') && (rule[j] != from[i]))
......@@ -272,6 +275,9 @@ std::string applyRule(const std::string & from, const std::string & rule)
exit(1);
}
if (!ruleIsAppliable(from, rule))
return applyRule(from, "@@");
unsigned int sepIndex;
for(sepIndex = 1; sepIndex < rule.size(); sepIndex++)
if(rule[sepIndex] == '@')
......
......@@ -119,6 +119,12 @@ void Trainer::train()
{
int neededActionIndex = classifier->getOracleActionIndex(trainConfig);
std::string neededActionName = classifier->getActionName(neededActionIndex);
if (ProgramParameters::debug)
{
trainConfig.printForDebug(stderr);
fprintf(stderr, "action=<%s>\n", neededActionName.c_str());
}
Action * action = classifier->getAction(neededActionName);
action->apply(trainConfig);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment