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/07/02 19:16:50 UTC

[incubator-nlpcraft] branch NLPCRAFT-504 updated: WIP + some fixes.

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

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


The following commit(s) were added to refs/heads/NLPCRAFT-504 by this push:
     new f5d0bd74 WIP + some fixes.
f5d0bd74 is described below

commit f5d0bd74acecabf4f63c43748e92535412892b5f
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Jul 2 12:16:45 2022 -0700

    WIP + some fixes.
---
 nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala            | 4 ++--
 nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala   | 3 ++-
 .../apache/nlpcraft/internal/conversation/NCConversationData.scala    | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
index 8360905c..02bb4634 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntity.scala
@@ -41,7 +41,7 @@ package org.apache.nlpcraft
 trait NCEntity extends NCPropertyMap:
 
     /**
-      * Gets the list of tokens this entity is comprised of. Ruturned list is never empty or {@code null}.
+      * Gets the list of tokens this entity is comprised of. Returned list is never empty or {@code null}.
       *
       * @return List of tokens that are part of this entity. */
     def getTokens: List[NCToken]
@@ -51,7 +51,7 @@ trait NCEntity extends NCPropertyMap:
       * result and performs text construction on each call. Make sure to cache the result to avoid
       * unnecessary parasitic workload if and when method {@link # getTokens ( )} does not change.
       *
-      * @return Constructuted textual representation of this entity. Note that returned value is not
+      * @return Constructed text value representation of this entity. Note that returned value is not
       * cached and created anew every time this method is called. */
     def mkText: String = getTokens.map(_.getText.trim).mkString(" ").trim
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
index f12229e8..05a475ed 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCPipelineBuilder.scala
@@ -188,12 +188,13 @@ class NCPipelineBuilder:
     def withSemantic(lang: String, macros: Map[String, String], elms: List[NCSemanticElement]): NCPipelineBuilder =
         Objects.requireNonNull(lang, "Language cannot be null.")
         Objects.requireNonNull(elms, "Model elements cannot be null.")
+        Objects.requireNonNull(macros, "Macros cannot be null.")
         if elms.isEmpty then throw new IllegalArgumentException("Model elements cannot be empty.")
 
         lang.toUpperCase match
             case "EN" =>
                 setEnComponents()
-                this.entParsers += NCSemanticEntityParser(mkEnStemmer, mkEnOpenNLPTokenParser, macros, elms)
+                entParsers += NCSemanticEntityParser(mkEnStemmer, mkEnOpenNLPTokenParser, macros, elms)
             case _ => throw new IllegalArgumentException("Unsupported language: " + lang)
         this
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/conversation/NCConversationData.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/conversation/NCConversationData.scala
index cca726a3..e3dfba4e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/conversation/NCConversationData.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/conversation/NCConversationData.scala
@@ -157,7 +157,7 @@ case class NCConversationData(
                 stepLogEntity(ents)
 
                 val registered = mutable.HashSet.empty[Seq[String]]
-                for (item <- stm.reverse; (gs, hs) <- item.holders.groupBy(t => if t.entity.getGroups != null then t.entity.getGroups else Seq.empty))
+                for (item <- stm.reverse; (gs, hs) <- item.holders.groupBy(t => if t.entity.getGroups.nonEmpty then t.entity.getGroups else Seq.empty))
                     val grps = gs.toSeq.sorted
 
                     // Reversed iteration.