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

Attach action changed so that it cannot replace an arc

parent 8d0d2b07
Branches
No related tags found
No related merge requests found
...@@ -581,10 +581,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: ...@@ -581,10 +581,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config::
{ {
auto apply = [governorObject, governorIndex, dependentObject, dependentIndex](Config & config, Action & a) 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); 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); addToHypothesisRelative(Config::childsColName, governorObject, governorIndex, std::to_string(depIndex)).apply(config, a);
a.data.emplace_back(std::to_string(config.getLastAttached())); a.data.emplace_back(std::to_string(config.getLastAttached()));
config.setLastAttached(depIndex); config.setLastAttached(depIndex);
...@@ -602,6 +602,7 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: ...@@ -602,6 +602,7 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config::
{ {
if (!config.hasRelativeWordIndex(governorObject, governorIndex) or !config.hasRelativeWordIndex(dependentObject, dependentIndex)) if (!config.hasRelativeWordIndex(governorObject, governorIndex) or !config.hasRelativeWordIndex(dependentObject, dependentIndex))
return false; return false;
long govLineIndex = config.getRelativeWordIndex(governorObject, governorIndex); long govLineIndex = config.getRelativeWordIndex(governorObject, governorIndex);
long depLineIndex = config.getRelativeWordIndex(dependentObject, dependentIndex); long depLineIndex = config.getRelativeWordIndex(dependentObject, dependentIndex);
...@@ -612,6 +613,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config:: ...@@ -612,6 +613,10 @@ Action Action::attach(Config::Object governorObject, int governorIndex, Config::
if (config.getAsFeature(Config::sentIdColName, govLineIndex) != config.getAsFeature(Config::sentIdColName, depLineIndex)) if (config.getAsFeature(Config::sentIdColName, govLineIndex) != config.getAsFeature(Config::sentIdColName, depLineIndex))
return false; return false;
// Check if dep is not already attached
if (!util::isEmpty(config.getAsFeature(Config::headColName, depLineIndex)))
return false;
// Check for cycles // Check for cycles
while (govLineIndex != depLineIndex) while (govLineIndex != depLineIndex)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment