From 078e0446f53e0f009fb89fee1c3f64a3a0329213 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Sat, 16 May 2020 17:05:10 +0200 Subject: [PATCH] Attach action changed so that it cannot replace an arc --- reading_machine/src/Action.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reading_machine/src/Action.cpp b/reading_machine/src/Action.cpp index 7bcca61..2908148 100644 --- a/reading_machine/src/Action.cpp +++ b/reading_machine/src/Action.cpp @@ -581,10 +581,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: { auto apply = [governorObject, governorIndex, dependentObject, dependentIndex](Config & config, Action & a) { - long lineIndex = config.getRelativeWordIndex(governorObject, governorIndex); + long govIndex = config.getRelativeWordIndex(governorObject, governorIndex); long depIndex = config.getRelativeWordIndex(dependentObject, dependentIndex); - addHypothesisRelative(Config::headColName, dependentObject, dependentIndex, std::to_string(lineIndex)).apply(config, a); + addHypothesisRelative(Config::headColName, dependentObject, dependentIndex, std::to_string(govIndex)).apply(config, a); addToHypothesisRelative(Config::childsColName, governorObject, governorIndex, std::to_string(depIndex)).apply(config, a); a.data.emplace_back(std::to_string(config.getLastAttached())); config.setLastAttached(depIndex); @@ -602,6 +602,7 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: { if (!config.hasRelativeWordIndex(governorObject, governorIndex) or !config.hasRelativeWordIndex(dependentObject, dependentIndex)) return false; + long govLineIndex = config.getRelativeWordIndex(governorObject, governorIndex); long depLineIndex = config.getRelativeWordIndex(dependentObject, dependentIndex); @@ -612,6 +613,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: if (config.getAsFeature(Config::sentIdColName, govLineIndex) != config.getAsFeature(Config::sentIdColName, depLineIndex)) return false; + // Check if dep is not already attached + if (!util::isEmpty(config.getAsFeature(Config::headColName, depLineIndex))) + return false; + // Check for cycles while (govLineIndex != depLineIndex) { -- GitLab