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

Fixed transitions cost

parent 5d34471e
No related branches found
No related tags found
No related merge requests found
...@@ -317,7 +317,7 @@ void Transition::initEagerRight_rel(std::string label) ...@@ -317,7 +317,7 @@ void Transition::initEagerRight_rel(std::string label)
if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1) if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1)
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
int cost = getNbLinkedWith(0, config.getStackSize()-1, Config::Object::Stack, config.getWordIndex(), config); int cost = getNbLinkedWith(1, config.getStackSize()-1, Config::Object::Stack, config.getWordIndex(), config);
if (bufferGovIndex != std::to_string(stackIndex)) if (bufferGovIndex != std::to_string(stackIndex))
++cost; ++cost;
...@@ -347,7 +347,7 @@ void Transition::initEagerRight() ...@@ -347,7 +347,7 @@ void Transition::initEagerRight()
if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1) if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1)
return std::numeric_limits<int>::max(); return std::numeric_limits<int>::max();
int cost = getNbLinkedWith(0, config.getStackSize()-1, Config::Object::Stack, config.getWordIndex(), config); int cost = getNbLinkedWith(1, config.getStackSize()-1, Config::Object::Stack, config.getWordIndex(), config);
if (bufferGovIndex != std::to_string(stackIndex)) if (bufferGovIndex != std::to_string(stackIndex))
++cost; ++cost;
...@@ -429,6 +429,7 @@ void Transition::initDeprel(std::string label) ...@@ -429,6 +429,7 @@ void Transition::initDeprel(std::string label)
int Transition::getNbLinkedWith(int firstIndex, int lastIndex, Config::Object object, int withIndex, const Config & config) int Transition::getNbLinkedWith(int firstIndex, int lastIndex, Config::Object object, int withIndex, const Config & config)
{ {
auto govIndex = config.getConst(Config::headColName, withIndex, 0); auto govIndex = config.getConst(Config::headColName, withIndex, 0);
auto govIndexPredicted = config.getAsFeature(Config::headColName, withIndex);
int nbLinkedWith = 0; int nbLinkedWith = 0;
...@@ -442,8 +443,11 @@ int Transition::getNbLinkedWith(int firstIndex, int lastIndex, Config::Object ob ...@@ -442,8 +443,11 @@ int Transition::getNbLinkedWith(int firstIndex, int lastIndex, Config::Object ob
continue; continue;
auto otherGovIndex = config.getConst(Config::headColName, index, 0); auto otherGovIndex = config.getConst(Config::headColName, index, 0);
auto otherGovIndexPredicted = config.getAsFeature(Config::headColName, index);
if (govIndex == std::to_string(index) || otherGovIndex == std::to_string(withIndex)) if (govIndex == std::to_string(index) and util::isEmpty(govIndexPredicted))
++nbLinkedWith;
if (otherGovIndex == std::to_string(withIndex) and util::isEmpty(otherGovIndexPredicted))
++nbLinkedWith; ++nbLinkedWith;
} }
......
...@@ -102,25 +102,6 @@ Transition * TransitionSet::getBestAppliableTransition(const Config & c) ...@@ -102,25 +102,6 @@ Transition * TransitionSet::getBestAppliableTransition(const Config & c)
} }
} }
if (!result)
{
for (unsigned int i = 0; i < transitions.size(); i++)
{
fmt::print(stderr, "{}\n", transitions[i].getName());
if (!transitions[i].appliable(c))
{
fmt::print(stderr, "not appliable\n");
continue;
}
fmt::print(stderr, "appliable\n");
int cost = transitions[i].getCost(c);
fmt::print(stderr, "cost {}\n", cost);
}
}
return result; return result;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment