diff --git a/reading_machine/src/Transition.cpp b/reading_machine/src/Transition.cpp index 28aae30c29ac3ab7f19c034e3b29c95d3a8d7d17..2dd88ee3210b8a1e2d173bacef5326d9180af572 100644 --- a/reading_machine/src/Transition.cpp +++ b/reading_machine/src/Transition.cpp @@ -317,7 +317,7 @@ void Transition::initEagerRight_rel(std::string label) if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1) 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)) ++cost; @@ -347,7 +347,7 @@ void Transition::initEagerRight() if (config.getConst(Config::EOSColName, config.getStack(0), 0) == Config::EOSSymbol1) 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)) ++cost; @@ -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) { auto govIndex = config.getConst(Config::headColName, withIndex, 0); + auto govIndexPredicted = config.getAsFeature(Config::headColName, withIndex); int nbLinkedWith = 0; @@ -442,8 +443,11 @@ int Transition::getNbLinkedWith(int firstIndex, int lastIndex, Config::Object ob continue; 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; } diff --git a/reading_machine/src/TransitionSet.cpp b/reading_machine/src/TransitionSet.cpp index 66da993267f524521836eaaa42358bd1de33a486..5701c70a46a9dabc04cbe53b8058ff5676ce62f7 100644 --- a/reading_machine/src/TransitionSet.cpp +++ b/reading_machine/src/TransitionSet.cpp @@ -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; }