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 2020/10/14 08:48:21 UTC
[incubator-nlpcraft] branch NLPCRAFT-150 created (now 2b67b7d)
This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a change to branch NLPCRAFT-150
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git.
at 2b67b7d WIP.
This branch includes the following new commits:
new 2b67b7d WIP.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[incubator-nlpcraft] 01/01: WIP.
Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-150
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit 2b67b7da7091a1275158a0a1c7e71de44f31496a
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Wed Oct 14 11:48:13 2020 +0300
WIP.
---
nlpcraft/pom.xml | 6 ++++++
.../scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala | 2 +-
.../org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala | 4 +++-
.../scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala | 5 +++--
4 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/nlpcraft/pom.xml b/nlpcraft/pom.xml
index 5608abb..1bbad24 100644
--- a/nlpcraft/pom.xml
+++ b/nlpcraft/pom.xml
@@ -371,8 +371,14 @@
<include>**/*.*</include>
</includes>
<excludes>
+ <!-- Some tests skipped on maven `verify` phase. -->
+ <!-- Reasons -->
+ <!-- Weather service is not stable enough and can be used for local tests only. -->
<exclude>**/NCConversationSpec.*</exclude>
+ <!-- Too huge output. -->
<exclude>**/NCDateGeneratorSpec.*</exclude>
+ <!-- ContextWordServer should be started. -->
+ <exclude>**/NCRestModelSpec.*</exclude>
</excludes>
</configuration>
</execution>
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
index 7742287..eaa2557 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/cmd/NCCommandManager.scala
@@ -112,7 +112,7 @@ object NCCommandManager extends NCService {
val macros = mdlData.model.getMacros.asInstanceOf[Serializable]
val syns = mdlData.model.getElements.asScala.map(p ⇒ p.getId → p.getSynonyms).toMap.asJava.asInstanceOf[Serializable]
- val samples = mdlData.samples.map(p ⇒ p._1 → p._2.asJava).asJava.asInstanceOf[Serializable]
+ val samples = mdlData.samples.map(p ⇒ p._1 → p._2.map(_.asJava).asJava).asJava.asInstanceOf[Serializable]
NCConnectionManager.send(
NCProbeMessage(
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
index f17892a..e9c97dc 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/sugsyn/NCSuggestSynonymManager.scala
@@ -186,7 +186,8 @@ object NCSuggestSynonymManager extends NCService {
val mdlSyns = m.get("synonyms").
asInstanceOf[util.Map[String, util.List[String]]].asScala.map(p ⇒ p._1 → p._2.asScala)
val mdlExs = m.get("samples").
- asInstanceOf[util.Map[String, util.List[String]]].asScala.map(p ⇒ p._1 → p._2.asScala)
+ asInstanceOf[util.Map[String, util.List[util.List[String]]]].asScala.
+ map(p ⇒ p._1 → p._2.asScala.flatMap(_.asScala.toSeq).distinct)
val minScore = minScoreOpt.getOrElse(DFLT_MIN_SCORE)
@@ -237,6 +238,7 @@ object NCSuggestSynonymManager extends NCService {
// Note that we don't use system tokenizer, because 'ctxword' module' doesn't have this tokenizer.
// We split examples words by spaces. We also treat separator as separate words.
+
val exs = mdlExs.
flatMap { case (_, samples) ⇒ samples }.
map(ex ⇒ SEPARATORS.foldLeft(ex)((s, ch) ⇒ s.replaceAll(s"\\$ch", s" $ch "))).
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
index e34eb84..5c337ce 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/server/rest/NCRestModelSpec.scala
@@ -24,8 +24,9 @@ import org.junit.jupiter.api.{Disabled, Test}
import scala.collection.JavaConverters._
-// Enable it and run if context word server started.
-@Disabled
+/**
+ * Note that context word server should be started.
+ */
@NCTestEnvironment(model = classOf[AlarmModel], startClient = false)
class NCRestModelSpec extends NCRestSpec {
@Test