diff --git a/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/dialog/nlu/ConfirmNLURegex.kt b/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/dialog/nlu/ConfirmNLURegex.kt index f5d1ea46..dafe5752 100644 --- a/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/dialog/nlu/ConfirmNLURegex.kt +++ b/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/dialog/nlu/ConfirmNLURegex.kt @@ -86,7 +86,7 @@ class ConfirmNLURegex : AbstractSkill(), SensorListener { private const val PS_YES = "confirmYes" } - private val finalReplacements = mapOf("""\bme\b""" to "you", """\byou\b""" to "me") + private val finalReplacements = mapOf("\bme\b" to "you","\\bme\\b" to "you", """\bme\b""" to "you", """\byou\b""" to "me", """ me\?""" to "you?") private var doFinalReplacements = true private var confirmText = "You want Me to: #M?" private var defaultMapping = "#T" @@ -142,7 +142,7 @@ class ConfirmNLURegex : AbstractSkill(), SensorListener { for (m in mappings.split(";")) { if (m.isBlank()) continue // last string after ; - logger.debug("add mapping: $m") + logger.trace("add mapping: $m") val s = m.trim().split("=") if (s.size != 2) throw SkillConfigurationException("error in intentMapping for '$m' size:${s.size} != 2") intentMapping[s.first()] = s.last() @@ -170,10 +170,13 @@ class ConfirmNLURegex : AbstractSkill(), SensorListener { } } logger.info("computed: '$result'") - if (doFinalReplacements) for (replacement in finalReplacements) { - result = result.replace(replacement.key.toRegex(), replacement.value) + if (doFinalReplacements) { + for (replacement in finalReplacements) { + + result = result.replace(replacement.key.toRegex(), replacement.value) + } + logger.info("text after final replacements: '$result'") } - logger.info("after final replacements: '$result'") return result } diff --git a/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/slots/CompareSlot.java b/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/slots/CompareSlot.java index e32c327e..85da0e28 100644 --- a/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/slots/CompareSlot.java +++ b/bonsai_skills/src/main/java/de/unibi/citec/clf/bonsai/skills/slots/CompareSlot.java @@ -33,7 +33,6 @@ public class CompareSlot extends AbstractSkill { private ExitToken tokenMisMatch; private ExitToken tokenMatch; - private ExitToken tokenError; private static final String KEY_COMPARE_STRING = "#_COMPARE_STRING"; @@ -46,7 +45,7 @@ public class CompareSlot extends AbstractSkill { public void configure(ISkillConfigurator configurator) { tokenMatch = configurator.requestExitToken(ExitStatus.SUCCESS().withProcessingStatus("match")); tokenMisMatch = configurator.requestExitToken(ExitStatus.SUCCESS().withProcessingStatus("misMatch")); - tokenError = configurator.requestExitToken(ExitStatus.ERROR()); + readSlot = configurator.getReadSlot("ReadSlot", String.class); compareString = configurator.requestValue(KEY_COMPARE_STRING); @@ -59,6 +58,7 @@ public boolean init() { if (slotContent == null) { logger.warn("your ReadSlot was empty"); + return false; } } catch (CommunicationException ex) { @@ -70,9 +70,6 @@ public boolean init() { @Override public ExitToken execute() { - if (slotContent == null) { - return tokenError; - } if (slotContent.equals(compareString)) { return tokenMatch; }