This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-170
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-170 by this push:
new 237dd48 WIP.
237dd48 is described below
commit 237dd48f669a62413a7959a80f6096237120330c
Author: Aaron Radzinski <[email protected]>
AuthorDate: Fri Dec 11 16:56:21 2020 -0800
WIP.
---
.../nlpcraft/model/tools/cmdline/NCCli.scala | 13 +++++----
.../nlpcraft/model/tools/cmdline/NCCliSpec.scala | 32 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 5 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 ee86953..f682ea0 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
@@ -534,6 +534,7 @@ object NCCli extends App {
*/
def resetServer(): Unit = {
isServerOnline = false
+ accessToken = None
serverLog = None
probes = Nil
}
@@ -1010,7 +1011,8 @@ object NCCli extends App {
s"Requires user to be already signed in. This command
${bo("only makes sense in the REPL mode")} as " +
s"it requires user to be signed in. REPL session keeps the
currently active access " +
s"token after user signed in. For command line mode, use
${c("'rest'")} command with " +
- s"corresponding parameters."
+ s"corresponding parameters. Note also that it requires a local
probe running that hosts " +
+ s"the specified model."
),
body = cmdSugSyn,
params = Seq(
@@ -1020,7 +1022,8 @@ object NCCli extends App {
value = Some("model.id"),
desc =
s"ID of the model to run synonym suggestion on. " +
- s"In REPL mode, hit ${rv(" Tab ")} to see
auto-suggestion for possible model IDs."
+ s"In REPL mode, hit ${rv(" Tab ")} to see
auto-suggestion for possible model IDs. " +
+ s"Note that the probe hosting this model must be
connected to the server."
),
Parameter(
id = "minScore",
@@ -1698,7 +1701,7 @@ object NCCli extends App {
* @return
*/
@tailrec
- private def stripQuotes(s: String): String = {
+ private[cmdline] def stripQuotes(s: String): String = {
val x = s.trim
if ((x.startsWith("\"") && x.endsWith("\"")) || (x.startsWith("'") &&
x.endsWith("'")))
@@ -3498,9 +3501,9 @@ object NCCli extends App {
logln(U.colorJson(U.prettyJson(resp.data)))
else {
if (resp.code == 200)
- logln(s"HTTP response: ${resp.data}")
+ logln(s"${g("HTTP response:")} ${resp.data}")
else
- error(s"HTTP error: ${resp.data}")
+ error(s"${r("HTTP error:")} ${resp.data}")
}
if (resp.code == 200) {
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
new file mode 100644
index 0000000..cbee4b4
--- /dev/null
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nlpcraft.model.tools.cmdline
+
+import org.junit.jupiter.api.Assertions._
+import org.junit.jupiter.api.Test
+
+/**
+ * Various tests for `NCCli` class.
+ */
+class NCCliSpec {
+ @Test
+ def testStripQuotes(): Unit = {
+ assertEquals(NCCli.stripQuotes("""'x'"""), "x")
+ assertEquals(NCCli.stripQuotes("""'"'x'" "z"'"""), """'x'" "z""")
+ }
+}