You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2022/10/21 05:52:59 UTC

[incubator-nlpcraft] branch master updated: Update CalculatorModel.scala

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


The following commit(s) were added to refs/heads/master by this push:
     new 191f3cbe Update CalculatorModel.scala
     new cd1c1718 Merge branch 'master' of https://github.com/apache/incubator-nlpcraft
191f3cbe is described below

commit 191f3cbee087fe49223cb8c0700599900b5e199a
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Thu Oct 20 22:52:46 2022 -0700

    Update CalculatorModel.scala
---
 .../nlpcraft/examples/time/CalculatorModel.scala      | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/nlpcraft-examples/calculator/src/main/scala/org/apache/nlpcraft/examples/time/CalculatorModel.scala b/nlpcraft-examples/calculator/src/main/scala/org/apache/nlpcraft/examples/time/CalculatorModel.scala
index 2d95c360..93d9bc8f 100644
--- a/nlpcraft-examples/calculator/src/main/scala/org/apache/nlpcraft/examples/time/CalculatorModel.scala
+++ b/nlpcraft-examples/calculator/src/main/scala/org/apache/nlpcraft/examples/time/CalculatorModel.scala
@@ -23,6 +23,7 @@ import org.apache.nlpcraft.nlp.entity.parser.stanford.*
 import org.apache.nlpcraft.nlp.parsers.*
 import org.apache.nlpcraft.nlp.token.parser.stanford.NCStanfordNLPTokenParser
 import java.util.Properties
+import scala.annotation.*
 
 /**
  *
@@ -55,15 +56,21 @@ class CalculatorModel extends NCModelAdapter(NCModelConfig("nlpcraft.calculator.
         mem = Some(OPS.getOrElse(op, throw new IllegalStateException()).apply(x, y))
         NCResult(mem.get)
 
+    /*
+     * We use '@unused' marker annotation on the intent callbacks since these
+     * callback are called by the system through reflection only and thus trigger
+     * IDEA warning about being unused in the code.
+     */
+
     @NCIntent(
         "intent=calc options={ 'ordered': true }" +
         "   term(x)={# == 'stanford:number'}" +
         "   term(op)={has(list('+', '-', '*', '/'), meta_ent('nlp:token:text')) == true}" +
         "   term(y)={# == 'stanford:number'}"
     )
-    def onMatch(
-        ctx: NCContext,
-        im: NCIntentMatch,
+    @unused def onMatch(
+        @unused ctx: NCContext,
+        @unused im: NCIntentMatch,
         @NCIntentTerm("x") x: NCEntity,
         @NCIntentTerm("op") op: NCEntity,
         @NCIntentTerm("y") y: NCEntity
@@ -74,9 +81,9 @@ class CalculatorModel extends NCModelAdapter(NCModelConfig("nlpcraft.calculator.
         "   term(op)={has(list('+', '-', '*', '/'), meta_ent('nlp:token:text')) == true}" +
         "   term(y)={# == 'stanford:number'}"
     )
-    def onMatchMem(
-        ctx: NCContext,
-        im: NCIntentMatch,
+    @unused def onMatchMem(
+        @unused ctx: NCContext,
+        @unused im: NCIntentMatch,
         @NCIntentTerm("op") op: NCEntity,
         @NCIntentTerm("y") y: NCEntity
     ): NCResult = calc(mem.getOrElse(throw new NCRejection("Memory is empty.")), op.mkText, nne(y))