This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git

commit bb995591f3d339ab7d56fc84ef4ef33248709a10
Author: Aaron Radzinski <[email protected]>
AuthorDate: Mon Mar 22 19:17:05 2021 -0700

    WIP.
---
 .../scala/org/apache/nlpcraft/examples/alarm/intents.idl  |  7 ++++---
 .../nlpcraft/model/intent/compiler/NCIdlCompiler.scala    |  3 ++-
 .../model/intent/solver/NCIntentSolverEngine.scala        | 15 ++++++++-------
 3 files changed, 14 insertions(+), 11 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/intents.idl 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/intents.idl
index f51d281..cb28dc4 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/intents.idl
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/alarm/intents.idl
@@ -19,9 +19,10 @@
 fragment=buzz term~{id() == 'x:alarm'}
 fragment=when
     term(nums)~{
-        id() == 'nlpcraft:num' &&
-        meta_token('nlpcraft:num:unittype') == 'datetime' &&
-        meta_token('nlpcraft:num:isequalcondition') == true
+        @type = meta_token('nlpcraft:num:unittype')
+        @iseq = meta_token('nlpcraft:num:isequalcondition')
+
+        id() == 'nlpcraft:num' && @type == 'datetime' && @iseq == true
     }[0,7]
 
 // Intents
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
index 1dfc42b..c3613ee 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompiler.scala
@@ -135,7 +135,8 @@ object NCIdlCompiler extends LazyLogging {
                 throw newSyntaxError(s"Unknown variable: @$varName")(ctx)
 
             val instr: SI = (tok: NCToken, stack: S, idlCtx: NCIdlContext) ⇒
-                stack.push(() ⇒ idlCtx.vars(varName)(tok, idlCtx))
+                 stack.push(() ⇒
+                     idlCtx.vars(varName)(tok, idlCtx))
 
             expr += instr
         }
diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
index e7ce6b3..b7675ca 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverEngine.scala
@@ -26,7 +26,7 @@ import org.apache.nlpcraft.model.impl.NCTokenLogger
 import org.apache.nlpcraft.model.{NCContext, NCDialogFlowItem, NCIntentMatch, 
NCResult, NCToken}
 import org.apache.nlpcraft.probe.mgrs.dialogflow.NCDialogFlowManager
 import org.apache.nlpcraft.model.impl.NCTokenPimp._
-import org.apache.nlpcraft.model.intent.{NCIdlContext, NCIdlIntent, 
NCIdlStackItem ⇒ Z, NCIdlTerm}
+import org.apache.nlpcraft.model.intent.{NCIdlContext, NCIdlFunction, 
NCIdlIntent, NCIdlTerm, NCIdlStackItem ⇒ Z}
 
 import java.util.function.Function
 import scala.collection.JavaConverters._
@@ -490,15 +490,16 @@ object NCIntentSolverEngine extends LazyLogging with 
NCOpenCensusTrace {
             var lastTermMatch: TermMatch = null
             
             val x = ctx.getConversation.getMetadata
-
-            val termCtx = NCIdlContext(
-                intentMeta = intent.meta,
-                convMeta = if (x.isEmpty) Map.empty[String, Object] else 
x.asScala.toMap[String, Object],
-                req = ctx.getRequest
-            )
+            val convMeta = if (x.isEmpty) Map.empty[String, Object] else 
x.asScala.toMap[String, Object]
 
             // Check terms.
             for (term ← intent.terms if !abort) {
+                val termCtx = NCIdlContext(
+                    intentMeta = intent.meta,
+                    convMeta = convMeta,
+                    req = ctx.getRequest
+                )
+
                 solveTerm(
                     term,
                     termCtx,

Reply via email to