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 02ad6671 Minor fixes.
02ad6671 is described below
commit 02ad6671c8383596840f4100f112663774b9c3bc
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu May 5 14:15:55 2022 +0300
Minor fixes.
---
.../nlpcraft/examples/pizzeria/PizzeriaModel.scala | 16 +++++++++-------
1 file changed, 9 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 c11f49c3..d1409a4d 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
@@ -83,13 +83,15 @@ object PizzeriaModel extends LazyLogging:
private def askShouldStop(): Result = mkDialog(s"Should current order be
canceled?") -> DIALOG_SHOULD_CANCEL
- private def doShowMenu(): NCResult =
+ private def doShowMenuResult(): NCResult =
mkResult(
"There are accessible for order: margherita, carbonara and
marinara. Sizes: large, medium or small. " +
- "Also there are tea, coffee and cola."
+ "Also there are tea, coffee and cola."
)
- private def doShowStatus(o: Order): NCResult = mkResult(s"Current order
state: ${o.getDescription}.")
+ private def doShowMenu(state: State): Result = doShowMenuResult() -> state
+
+ private def doShowStatus(o: Order, state: State): Result =
mkResult(s"Current order state: ${o.getDescription}.") -> state
private def askConfirm(o: Order): Result =
require(o.isValid)
@@ -178,8 +180,8 @@ class PizzeriaModel extends NCModelAdapter(new
NCModelConfig("nlpcraft.pizzeria.
def onStatus(using im: NCIntentMatch): NCResult = doRequest(
o => o.getState match
case DIALOG_CONFIRM => askConfirm(o) // Ignore `status`, confirm
again.
- case DIALOG_SHOULD_CANCEL => doShowStatus(o) -> DIALOG_EMPTY //
Changes state.
- case DIALOG_EMPTY | DIALOG_IS_READY | DIALOG_SPECIFY =>
doShowStatus(o) -> o.getState // Keeps same state.
+ case DIALOG_SHOULD_CANCEL => doShowStatus(o, DIALOG_EMPTY) //
Changes state.
+ case DIALOG_EMPTY | DIALOG_IS_READY | DIALOG_SPECIFY =>
doShowStatus(o, o.getState) // Keeps same state.
)
/**
*
@@ -200,7 +202,7 @@ class PizzeriaModel extends NCModelAdapter(new
NCModelConfig("nlpcraft.pizzeria.
*/
@NCIntent("intent=menu term(menu)={# == 'ord:menu'}")
// It doesn't depend and doesn't influence on order validity and dialog
state.
- def onMenu(using im: NCIntentMatch): NCResult = doRequest(o =>
doShowMenu() -> o.getState)
+ def onMenu(using im: NCIntentMatch): NCResult = doRequest(o =>
doShowMenu(o.getState))
/**
*
@@ -232,4 +234,4 @@ class PizzeriaModel extends NCModelAdapter(new
NCModelConfig("nlpcraft.pizzeria.
override def onRejection(im: NCIntentMatch, e: NCRejection): NCResult =
// TODO: improve logic after
https://issues.apache.org/jira/browse/NLPCRAFT-495 ticket resolving.
- if im == null || getOrder(im.getContext).isEmpty then doShowMenu()
else throw e
\ No newline at end of file
+ if im == null || getOrder(im.getContext).isEmpty then throw e else
doShowMenuResult()
\ No newline at end of file