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 727c194 WIP.
727c194 is described below
commit 727c1946e682c9a6f586ff9e13150c0dae1cdb2e
Author: unknown <[email protected]>
AuthorDate: Tue Jun 8 13:48:49 2021 -0700
WIP.
---
.../model/intent/compiler/NCIdlCompilerBase.scala | 15 ++++++++++++---
.../compiler/functions/NCIdlFunctionsCollections.scala | 7 +++++--
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
index e314cba..30b8eda 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/compiler/NCIdlCompilerBase.scala
@@ -30,6 +30,7 @@ import java.time.temporal.IsoFields
import java.time.{LocalDate, LocalTime}
import java.util
import java.util.{Calendar, Collections, Collection => JColl, List => JList,
Map => JMap}
+
import scala.jdk.CollectionConverters.{CollectionHasAsScala, IterableHasAsJava}
trait NCIdlCompilerBase {
@@ -684,7 +685,7 @@ trait NCIdlCompilerBase {
val jl = new util.ArrayList[Object]()
var z = 0
- dump.foreach { x =>
+ dump.toSeq.reverse.foreach { x =>
val Z(v, n) = x()
z += n
@@ -870,7 +871,10 @@ trait NCIdlCompilerBase {
stack.push(() => {
val Z(v, n) = x()
- val jl = toList(v).asScala.toSeq.distinct.asJava
+ val jl = new util.ArrayList[Object]()
+
+ for (d <- toList(v).asScala.toSeq.distinct)
+ jl.add(d.asInstanceOf[Object])
Z(jl, n)
})
@@ -882,7 +886,12 @@ trait NCIdlCompilerBase {
stack.push(() => {
val (lst1, lst2, n) = extract2(x1, x2)
- Z((toList(lst1).asScala ++ toList(lst2).asScala).asJava, n)
+ val jl = new util.ArrayList[Object]()
+
+ for (d <- toList(lst1).asScala ++ toList(lst2).asScala)
+ jl.add(d.asInstanceOf[Object])
+
+ Z(jl, n)
})
}
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 45e42b6..583383a 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
@@ -44,7 +44,10 @@ class NCIdlFunctionsCollections extends NCIdlFunctions {
"has_any(list('1', '2', '3'), list('10', '20', '30')) == false",
"has_all(list('1', '2', '3'), list('1', '20', '30')) == false",
"has_all(list('1', '2', '3'), list('1', '2', '3')) == true",
+ "size(list()) == 0",
+ "list(1, 2, 3) == list(1, 2, 3)",
"first(list(1, 2, 3)) == 1",
+ "get(list(1, 2, 3), 0) == 1",
"@lst = list(1, 2, 3) first(reverse(@lst)) == last(@lst)",
"last(list(1, 2, 3)) == 3",
"is_empty(list()) == true",
@@ -62,10 +65,10 @@ class NCIdlFunctionsCollections extends NCIdlFunctions {
"count(list()) == 0",
s"keys(json('$js')) == list('k1')",
s"values(json('$js')) == list('v1')",
- "distinct(list(1, 2, 3, 3, 2)) == list(1, 2, 3)",
+ "sort(distinct(list(1, 2, 3, 3, 2))) == sort(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)",
+ "sort(concat(list(1, 2, 3), list(1, 2, 3))) == sort(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)"