From 673b4d2aa059cdd98394be5775920c2f906f69eb Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Thu, 18 Jun 2020 19:11:02 +0200 Subject: [PATCH] Removed cycle checking in Action::attach and fixed index problem in some transition cost --- reading_machine/src/Action.cpp | 19 ++++++++----------- reading_machine/src/Transition.cpp | 4 ++-- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/reading_machine/src/Action.cpp b/reading_machine/src/Action.cpp index 26fe984..eb03c35 100644 --- a/reading_machine/src/Action.cpp +++ b/reading_machine/src/Action.cpp @@ -667,15 +667,15 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: return false; // Check for cycles - while (govLineIndex != depLineIndex) - { - try - { - govLineIndex = std::stoi(config.getAsFeature(Config::headColName, govLineIndex)); - } catch(std::exception &) {return true;} - } +// while (govLineIndex != depLineIndex) +// { +// try +// { +// govLineIndex = std::stoi(config.getAsFeature(Config::headColName, govLineIndex)); +// } catch(std::exception &) {return true;} +// } - return false; + return true; }; return {Type::Write, apply, undo, appliable}; @@ -743,9 +743,6 @@ Action Action::setRootUpdateIdsEmptyStackIfSentChanged() firstIndexOfSentence = i; } - if (firstIndexOfSentence < 0) - util::myThrow("could not find any token in current sentence"); - for (int i = firstIndexOfSentence; i <= lineIndex; ++i) { if (!config.has(0, i, 0)) diff --git a/reading_machine/src/Transition.cpp b/reading_machine/src/Transition.cpp index 76601d3..7fcc7ca 100644 --- a/reading_machine/src/Transition.cpp +++ b/reading_machine/src/Transition.cpp @@ -362,7 +362,7 @@ void Transition::initStandardLeft_rel(std::string label) return 0; int cost = getNbLinkedWith(config.getWordIndex(), getLastIndexOfSentence(config.getWordIndex(), config), Config::Object::Buffer, depIndex, config); - cost += getNbLinkedWith(1, config.getStackSize()-2, Config::Object::Stack, depIndex, config); + cost += getNbLinkedWith(1, config.getStackSize()-1, Config::Object::Stack, depIndex, config); if (label != config.getConst(Config::deprelColName, depIndex, 0)) ++cost; @@ -406,7 +406,7 @@ void Transition::initEagerRight_rel(std::string label) { auto depIndex = config.getWordIndex(); - int cost = getNbLinkedWith(1, config.getStackSize()-2, Config::Object::Stack, depIndex, config); + int cost = getNbLinkedWith(1, config.getStackSize()-1, Config::Object::Stack, depIndex, config); cost += getNbLinkedWithHead(depIndex+1, getLastIndexOfSentence(depIndex, config), Config::Object::Buffer, depIndex, config); if (label != config.getConst(Config::deprelColName, depIndex, 0)) -- GitLab