You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2022/02/01 08:37:22 UTC

[incubator-nlpcraft] branch master updated: Minor fixes.

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

sergeykamov 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 bf151f1  Minor fixes.
bf151f1 is described below

commit bf151f149f1596025f6ba7cb8325862d2d04d495
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Tue Feb 1 11:37:12 2022 +0300

    Minor fixes.
---
 .../scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala  | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
index 7b37671..98da85d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/impl/NCModelScanner.scala
@@ -495,7 +495,7 @@ object NCModelScanner extends LazyLogging:
 
         val cfg = mdl.getConfig
         lazy val z = s"mdlId=${cfg.getId}"
-        val intents = mutable.Buffer.empty[IntentHolder]
+        val intentsMtds = mutable.HashMap.empty[Method, IntentHolder]
         val intentDecls = mutable.HashMap.empty[String, NCIDLIntent]
         val objs = mutable.Buffer.empty[AnyRef]
         val processed = mutable.HashSet.empty[Class[_]]
@@ -508,8 +508,8 @@ object NCModelScanner extends LazyLogging:
             intentDecls += intent.id -> intent
 
         def addIntent(intent: NCIDLIntent, mtd: Method, obj: AnyRef): Unit =
-            if intents.exists(_.method == mtd) then E(s"The callback cannot have more one intent [$z, callback=${method2Str(mtd)}]")
-            intents += IntentHolder(cfg, intent, obj, mtd)
+            if intentsMtds.contains(mtd) then E(s"The callback cannot have more one intent [$z, callback=${method2Str(mtd)}]")
+            intentsMtds += mtd -> IntentHolder(cfg, intent, obj, mtd)
 
         def processClassAnnotations(cls: Class[_]): Unit =
             if cls != null && processed.add(cls) then
@@ -559,6 +559,8 @@ object NCModelScanner extends LazyLogging:
             addDecl(intent)
             addIntent(intent, mtd, obj)
 
+        val intents = intentsMtds.values
+
         val unusedIds = intentDecls.keys.filter(k => !intents.exists(_.intent.id == k))
         if unusedIds.nonEmpty then
             logger.warn(s"Intents are unused (have no callback): [$z, intentIds=${col2Str(unusedIds)}]")