This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-296
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-296 by this push:
new df2dd40 WIP.
df2dd40 is described below
commit df2dd40cdcb43f5459bf3db3073b3c53beecd3ff
Author: unknown <[email protected]>
AuthorDate: Tue Jun 8 13:11:02 2021 -0700
WIP.
---
.../apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala | 2 +-
.../server/nlp/core/stanford/NCStanfordAnnotator.scala | 9 +++++----
.../server/nlp/core/stanford/NCStanfordTokenizer.scala | 2 +-
.../idl/compiler/functions/NCIdlFunctionsCollections.scala | 14 +++++++-------
4 files changed, 14 insertions(+), 13 deletions(-)
diff --git
a/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
b/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
index 80b836f..2d11c56 100644
---
a/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
+++
b/nlpcraft-examples/sql/src/test/java/org/apache/nlpcraft/examples/sql/NCSqlExampleSpec.scala
@@ -173,7 +173,7 @@ class NCSqlExampleSpec extends NCTestContext {
}
@Test
- def test() {
+ def test(): Unit = {
check(
Case(
Seq(
diff --git
a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordAnnotator.scala
b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordAnnotator.scala
index dcb922a..278d234 100644
---
a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordAnnotator.scala
+++
b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordAnnotator.scala
@@ -25,8 +25,9 @@ import edu.stanford.nlp.pipeline.{Annotation, Annotator}
import edu.stanford.nlp.process.AbstractTokenizer
import edu.stanford.nlp.util.TypesafeMap
+import scala.jdk.CollectionConverters.CollectionHasAsScala
+
import scala.language.implicitConversions
-import collection.convert.ImplicitConversions._
/**
* Custom annotator.
@@ -71,8 +72,8 @@ class NCStanfordAnnotator extends Annotator {
*
* @param toks
*/
- private def setNewlineStatus(toks: util.List[CoreLabel]): Unit = // label
newlines
- for (tok <- toks)
+ private def setNewlineStatus(toks: util.List[CoreLabel]): Unit =
+ for (tok <- toks.asScala)
tok.set(
classOf[IsNewlineAnnotation],
tok.word == AbstractTokenizer.NEWLINE_TOKEN &&
(tok.endPosition - tok.beginPosition == 1)
@@ -83,7 +84,7 @@ class NCStanfordAnnotator extends Annotator {
* @param toks
*/
private def setTokenBeginTokenEnd(toks: util.List[CoreLabel]): Unit =
- toks.zipWithIndex.foreach { case (tok, idx) =>
+ toks.asScala.zipWithIndex.foreach { case (tok, idx) =>
tok.set(classOf[TokenBeginAnnotation], idx)
tok.set(classOf[TokenEndAnnotation], idx + 1)
}
diff --git
a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordTokenizer.scala
b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordTokenizer.scala
index cdc166a..f95dfe0 100644
---
a/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordTokenizer.scala
+++
b/nlpcraft-stanford/src/main/scala/org/apache/nlpcraft/server/nlp/core/stanford/NCStanfordTokenizer.scala
@@ -27,7 +27,7 @@ import NCStanfordTokenizer._
* Custom tokenizer.
*/
case class NCStanfordTokenizer(sen: String) extends
AbstractTokenizer[CoreLabel] {
- private val iter = NCNlpCoreManager.tokenize(sen).map(p =>
factory.makeToken(p.token, p.from, p.length)).toIterator
+ private val iter = NCNlpCoreManager.tokenize(sen).map(p =>
factory.makeToken(p.token, p.from, p.length)).iterator
override def getNext: CoreLabel = if (iter.hasNext) iter.next() else null
}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
index b5ad3aa..45e42b6 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/idl/compiler/functions/NCIdlFunctionsCollections.scala
@@ -62,12 +62,12 @@ class NCIdlFunctionsCollections extends NCIdlFunctions {
"count(list()) == 0",
s"keys(json('$js')) == list('k1')",
s"values(json('$js')) == list('v1')",
- s"distinct(list(1, 2, 3, 3, 2)) == list(1, 2, 3)",
- s"distinct(list(1.0, 2.0, 3.0, 3.0, 2.0)) == list(1.0, 2.0, 3.0)",
- s"distinct(list('1', '2', '3', '3', '2')) == list('1', '2', '3')",
- s"concat(list(1, 2, 3), list(1, 2, 3)) == list(1, 2, 3, 1, 2, 3)",
- s"concat(list(1, 2, 3), list()) == list(1, 2, 3)",
- s"concat(list(), list()) == list()",
- s"concat(list(1, 2), list(3.0)) == list(1, 2, 3.0)"
+ "distinct(list(1, 2, 3, 3, 2)) == list(1, 2, 3)",
+ "distinct(list(1.0, 2.0, 3.0, 3.0, 2.0)) == list(1.0, 2.0, 3.0)",
+ "distinct(list('1', '2', '3', '3', '2')) == list('1', '2', '3')",
+ "concat(list(1, 2, 3), list(1, 2, 3)) == list(1, 2, 3, 1, 2, 3)",
+ "concat(list(1, 2, 3), list()) == list(1, 2, 3)",
+ "concat(list(), list()) == list()",
+ "concat(list(1, 2), list(3.0)) == list(1, 2, 3.0)"
)
}