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

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


The following commit(s) were added to refs/heads/NLPCRAFT-491 by this push:
     new 71e89b71 WIP.
71e89b71 is described below

commit 71e89b71e1037778d987a8d886b5fbf2b8b2ca37
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Apr 7 20:52:40 2022 +0300

    WIP.
---
 .../apache/nlpcraft/examples/pizzeria/PizzeriaModel.scala   | 13 +++++++------
 .../apache/nlpcraft/examples/pizzeria/PizzeriaOrder.scala   |  2 +-
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git 
a/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaModel.scala
 
b/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaModel.scala
index ab5a69f9..5b23da64 100644
--- 
a/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaModel.scala
+++ 
b/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaModel.scala
@@ -51,18 +51,20 @@ class PizzeriaModel extends NCModelAdapter (new 
NCModelConfig("nlpcraft.pizzeria
     private def withLog(im: NCIntentMatch, body: PizzeriaOrder => NCResult): 
NCResult =
         val usrId = im.getContext.getRequest.getUserId
         val data = im.getContext.getConversation.getData
-
         var o: PizzeriaOrder = data.get(usrId)
 
         if o == null then
             o = new PizzeriaOrder()
             data.put(usrId, o)
 
-        def getState: String = o.getState.toString.toLowerCase
-        val state = getState
+        val initState = o.getState.toString.toLowerCase
+        val initDesc = o.getDesc
 
         try body.apply(o)
-        finally println(s"'${im.getIntentId}' called ($state -> $getState)")
+        finally
+            println(s"'${im.getIntentId}' called.")
+            println(s"Initial state: $initDesc, state: $initState")
+            println(s"Finish state:  ${o.getDesc}, state:  
${o.getState.toString.toLowerCase}")
 
     private def askIsReady(o: PizzeriaOrder): NCResult =
         val res = NCResult(s"Is order ready?", ASK_DIALOG)
@@ -200,7 +202,7 @@ class PizzeriaModel extends NCModelAdapter (new 
NCModelConfig("nlpcraft.pizzeria
     def onOrderPizzaSize(im: NCIntentMatch, @NCIntentTerm("size") size: 
NCEntity): NCResult = withLog(
         im,
         (o: PizzeriaOrder) =>
-            // If order in progress and has pizza with unknown size -it 
doesn't depend on dialog state.
+            // If order in progress and has pizza with unknown size, it 
doesn't depend on dialog state.
             if !o.isEmpty then
                 if o.setPizzaNoSize(extractPizzaSize(size)) then 
askIsReadyOrAskSpecify(o) else throw UNEXPECTED_REQUEST
             else
@@ -218,7 +220,6 @@ class PizzeriaModel extends NCModelAdapter (new 
NCModelConfig("nlpcraft.pizzeria
             case DIALOG_CONFIRM =>
                 require(o.isValid);
                 askConfirm(o) // Ignore `status`, confirm again.
-            //case DIALOG_SPECIFY => askSpecify(o) // Ignore `status`, specify 
again.
             case DIALOG_SHOULD_CANCEL => doShowStatus(o, NO_DIALOG) // Changes 
state.
             case NO_DIALOG | DIALOG_IS_READY | DIALOG_SPECIFY => 
doShowStatus(o, o.getState)  // Keeps same state.
         )
diff --git 
a/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaOrder.scala
 
b/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaOrder.scala
index 81dee08e..3b6a03d9 100644
--- 
a/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaOrder.scala
+++ 
b/nlpcraft-examples/pizzeria/src/main/java/org/apache/nlpcraft/examples/pizzeria/PizzeriaOrder.scala
@@ -142,7 +142,7 @@ class PizzeriaOrder:
         if !isEmpty then
             def s(name: String, seq: Iterable[String]): String = if 
seq.nonEmpty then s"$name: ${seq.mkString(", ")}" else ""
             def p2s(p: Pizza) = s"${p.name}, '${p.size.getOrElse("undefined 
size")}' ${p.qty.getOrElse(DFLT_QTY)} p."
-            def d2s(d: Drink) = s"${d.name},  ${d.qty.getOrElse(DFLT_QTY)} p."
+            def d2s(d: Drink) = s"${d.name}, ${d.qty.getOrElse(DFLT_QTY)} p."
 
             val s1 = s("Pizza", getPizzas.map(p2s))
             val s2 = s("Drinks", getDrinks.map(d2s))

Reply via email to