This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-472
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-472 by this push:
new 44a9d1c WIP.
44a9d1c is described below
commit 44a9d1c40244f00f8cf0bdf55e799f3df7a5a4dc
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Dec 30 22:41:13 2021 +0300
WIP.
---
.../semantic/impl/NCSemanticSynonymsProcessor.scala | 16 +++++++++-------
.../tokenizer/opennlp/impl/NCOpenNlpTokenizerImpl.scala | 2 +-
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
index a75f870..9577451 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/entity/parser/semantic/impl/NCSemanticSynonymsProcessor.scala
@@ -52,7 +52,9 @@ private[impl] object NCSemanticSynonymsProcessor extends
LazyLogging:
*/
private def checkMacros(macros: Map[String, String], elements:
Seq[NCSemanticElement]): Unit =
if macros != null then
- if macros.contains(null) then throw new NCException("Some macro
are null")
+ // TODO: check empty.
+ if macros.contains(null) then throw new NCException("Some macro
names are null")
+ if macros.values.contains(null) then throw new NCException("Some
macro bodies are null")
val set = elements.filter(_.getSynonyms !=
null).flatMap(_.getSynonyms.asScala) ++ macros.values
@@ -98,20 +100,20 @@ private[impl] object NCSemanticSynonymsProcessor extends
LazyLogging:
)
/**
*
- * @param elements
+ * @param elems
*/
- private def checkElements(elements: Seq[NCSemanticElement]): Unit =
- if elements == null || elements.isEmpty then throw new
NCException("Elements cannot be null or empty")
- if elements.contains(null) then throw new NCException("Some elements
are null")
+ private def checkElements(elems: Seq[NCSemanticElement]): Unit =
+ if elems == null || elems.isEmpty then throw new NCException("Elements
cannot be null or empty")
+ if elems.contains(null) then throw new NCException("Some elements are
null")
// Duplicates.
val ids = mutable.HashSet.empty[String]
- for (id <- elements.map(_.getId))
+ for (id <- elems.map(_.getId))
if ids.contains(id) then throw new NCException(s"Duplicate element
ID [element=$id]")
else ids += id
- for (e <- elements)
+ for (e <- elems)
val elemId = e.getId
if elemId == null || elemId.isEmpty then
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/tokenizer/opennlp/impl/NCOpenNlpTokenizerImpl.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/tokenizer/opennlp/impl/NCOpenNlpTokenizerImpl.scala
index 65a541d..9db5c1e 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/tokenizer/opennlp/impl/NCOpenNlpTokenizerImpl.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/nlp/tokenizer/opennlp/impl/NCOpenNlpTokenizerImpl.scala
@@ -27,7 +27,7 @@ import scala.jdk.CollectionConverters.*
/**
*
- * @param is
+ * @param src
*/
class NCOpenNlpTokenizerImpl(src: String) extends NCTokenizer:
@volatile var tokenizer: TokenizerME = _