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 2021/07/24 23:33:05 UTC
[incubator-nlpcraft] branch NLPCRAFT-371 updated: WIP on
NLPCRAFT-371.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-371
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-371 by this push:
new 019ac6f WIP on NLPCRAFT-371.
019ac6f is described below
commit 019ac6fb75f017c6306761d4d3f96afb59c16efb
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Jul 24 16:32:54 2021 -0700
WIP on NLPCRAFT-371.
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 33 ++++++++++++++++++++--
.../nlpcraft/model/tools/cmdline/NCCliBase.scala | 9 +++---
.../nlpcraft/server/rest/NCBasicRestApi.scala | 4 ++-
3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
index 09cc21b..608adbe 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCli.scala
@@ -2568,17 +2568,46 @@ object NCCli extends NCCliBase {
// For 'ask' and 'sugysn' - add additional model IDs auto-completion/suggestion candidates.
if (cmd == ASK_CMD.name || cmd == MODEL_SUGSYN_CMD.name || cmd == MODEL_SYNS_CMD.name)
candidates.addAll(
- state.probes.flatMap(_.models.toList).map(mdl => {
+ state.probes.flatMap(_.models.toList).map(mdl =>
mkCandidate(
disp = s"--mdlId=${mdl.id}",
grp = MANDATORY_GRP,
desc = null,
completed = true
)
- })
+ )
.asJava
)
+ // For 'model-syns' add auto-completion for element IDs.
+ if (cmd == MODEL_SYNS_CMD.name) {
+ val mdlIdParam = MODEL_SYNS_CMD.findParameterById("mdlId")
+
+ words.find(w => mdlIdParam.names.exists(x => w.startsWith(x))) match {
+ case Some(p) =>
+ val mdlId = p.substring(p.indexOf('=') + 1)
+
+ state.probes.flatMap(_.models).find(_.id == mdlId) match {
+ case Some(mdl) =>
+ candidates.addAll(
+ mdl.elementIds.toList.map(id =>
+ mkCandidate(
+ disp = s"--elmId=$id",
+ grp = MANDATORY_GRP,
+ desc = null,
+ completed = true
+ )
+ )
+ .asJava
+ )
+
+ case None => ()
+ }
+
+ case None => ()
+ }
+ }
+
// For 'call' - add additional auto-completion/suggestion candidates.
if (cmd == CALL_CMD.name) {
val pathParam = CALL_CMD.findParameterById("path")
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
index 96c219c..0bd7531 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliBase.scala
@@ -121,10 +121,11 @@ class NCCliBase extends App {
// See NCProbeModelMdo.
case class ProbeModel(
- id: String,
- name: String,
- version: String,
- enabledBuiltInTokens: Array[String]
+ id: String,
+ name: String,
+ version: String,
+ elementIds: Array[String],
+ enabledBuiltInTokens: Array[String]
)
case class ProbeAllResponse(
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
index 4dcb4ec..e74fb68 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/server/rest/NCBasicRestApi.scala
@@ -1781,6 +1781,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w
id: String,
name: String,
version: String,
+ elementIds: Set[String],
enabledBuiltInTokens: Set[String]
)
case class Probe_Probe$All(
@@ -1810,7 +1811,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w
)
implicit val reqFmt: RootJsonFormat[Req$Probe$All] = jsonFormat1(Req$Probe$All)
- implicit val mdlFmt: RootJsonFormat[Model_Probe$All] = jsonFormat4(Model_Probe$All)
+ implicit val mdlFmt: RootJsonFormat[Model_Probe$All] = jsonFormat5(Model_Probe$All)
implicit val probFmt: RootJsonFormat[Probe_Probe$All] = jsonFormat19(Probe_Probe$All)
implicit val resFmt: RootJsonFormat[Res$Probe$All] = jsonFormat2(Res$Probe$All)
@@ -1843,6 +1844,7 @@ class NCBasicRestApi extends NCRestApi with LazyLogging with NCOpenCensusTrace w
m.id,
m.name,
m.version,
+ m.elementIds,
m.enabledBuiltInTokens
))
))