From 8749d5f35bd7f6400ed903dab7639054a7d67422 Mon Sep 17 00:00:00 2001
From: Franck Dary <franck.dary@lis-lab.fr>
Date: Mon, 30 Mar 2020 22:06:28 +0200
Subject: [PATCH] splitword cannot happen if current form is not empty

---
 reading_machine/include/Action.hpp | 2 +-
 reading_machine/src/Action.cpp     | 6 +++---
 reading_machine/src/Transition.cpp | 5 +++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/reading_machine/include/Action.hpp b/reading_machine/include/Action.hpp
index 17e7114..f2435e6 100644
--- a/reading_machine/include/Action.hpp
+++ b/reading_machine/include/Action.hpp
@@ -58,7 +58,7 @@ class Action
   static Action setRoot();
   static Action updateIds();
   static Action endWord();
-  static Action assertIdIsEmpty();
+  static Action assertIsEmpty(const std::string & colName);
   static Action attach(Object governorObject, int governorIndex, Object dependentObject, int dependentIndex);
   static Action addCurCharToCurWord();
   static Action ignoreCurrentCharacter();
diff --git a/reading_machine/src/Action.cpp b/reading_machine/src/Action.cpp
index dbe4c12..47c5d20 100644
--- a/reading_machine/src/Action.cpp
+++ b/reading_machine/src/Action.cpp
@@ -370,7 +370,7 @@ Action Action::ignoreCurrentCharacter()
   return {Type::MoveChar, apply, undo, appliable}; 
 }
 
-Action Action::assertIdIsEmpty()
+Action Action::assertIsEmpty(const std::string & colName)
 {
   auto apply = [](Config &, Action &)
   {
@@ -380,9 +380,9 @@ Action Action::assertIdIsEmpty()
   {
   };
 
-  auto appliable = [](const Config & config, const Action &)
+  auto appliable = [colName](const Config & config, const Action &)
   {
-    return util::isEmpty(config.getAsFeature(Config::idColName, config.getWordIndex()));
+    return util::isEmpty(config.getAsFeature(colName, config.getWordIndex()));
   };
 
   return {Type::Check, apply, undo, appliable}; 
diff --git a/reading_machine/src/Transition.cpp b/reading_machine/src/Transition.cpp
index 11ad8e9..a8d3b33 100644
--- a/reading_machine/src/Transition.cpp
+++ b/reading_machine/src/Transition.cpp
@@ -164,7 +164,7 @@ void Transition::initEndWord()
 
 void Transition::initAddCharToWord()
 {
-  sequence.emplace_back(Action::assertIdIsEmpty());
+  sequence.emplace_back(Action::assertIsEmpty(Config::idColName));
   sequence.emplace_back(Action::addLinesIfNeeded(0));
   sequence.emplace_back(Action::addCurCharToCurWord());
   sequence.emplace_back(Action::moveCharacterIndex(1));
@@ -191,7 +191,8 @@ void Transition::initAddCharToWord()
 void Transition::initSplitWord(std::vector<std::string> words)
 {
   auto & consumedWord = words[0];
-  sequence.emplace_back(Action::assertIdIsEmpty());
+  sequence.emplace_back(Action::assertIsEmpty(Config::idColName));
+  sequence.emplace_back(Action::assertIsEmpty("FORM"));
   sequence.emplace_back(Action::addLinesIfNeeded(words.size()));
   sequence.emplace_back(Action::consumeCharacterIndex(consumedWord));
   for (unsigned int i = 0; i < words.size(); i++)
-- 
GitLab