This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-520
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-520 by this push:
new 6f65a77e WIP.
6f65a77e is described below
commit 6f65a77e2a1b5871811cbfc6b38823b15102829c
Author: Sergey Kamov <[email protected]>
AuthorDate: Tue Dec 20 00:22:43 2022 +0400
WIP.
---
.../intent/compiler/functions/NCIDLFunctions.scala | 9 +++++++--
.../compiler/functions/NCIDLFunctionsEntitiesUsed.scala | 2 ++
.../intent/compiler/functions/NCIDLFunctionsEntity.scala | 16 +++++++++-------
.../intent/compiler/functions/NCIDLFunctionsMeta.scala | 1 +
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
index e2de685c..f6c84d55 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctions.scala
@@ -33,6 +33,12 @@ import scala.language.implicitConversions
private[functions] object NCIDLFunctions:
private final val MODEL_ID = "test.mdl.id"
+ given Conversion[NCTestToken, Seq[NCTestToken]] with
+ def apply(t: NCTestToken): Seq[NCTestToken] = Seq(t)
+
+ given Conversion[String, TestDesc] with
+ def apply(truth: String): TestDesc = TestDesc(truth)
+
/**
*
* @param truth
@@ -86,8 +92,7 @@ private[functions] object NCIDLFunctions:
def apply(truth: String, entity: NCEntity): TestDesc =
new TestDesc(truth = truth, entity = entity.?, idlCtx =
mkIdlContext(entities = Seq(entity)))
- given Conversion[String, TestDesc] with
- def apply(truth: String): TestDesc = TestDesc(truth)
+
/**
*
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
index 99ff31bd..63b3f19b 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntitiesUsed.scala
@@ -18,6 +18,8 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
+import scala.language.implicitConversions
+import
org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.given
import org.apache.nlpcraft.nlp.util.NCTestToken
import org.apache.nlpcraft.*
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
index 3fa008c8..b55b6af5 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsEntity.scala
@@ -18,6 +18,7 @@
package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
+import
org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.given
import org.apache.nlpcraft.nlp.util.NCTestToken
import java.lang.{Boolean as JBool, Integer as JInt}
@@ -30,17 +31,18 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
test("test") {
val t1 = NCTestToken(txt = "W1", idx = 0)
val t2 = NCTestToken(txt = "w2", idx = 1)
+ val t1t2 = Seq(t1, t2)
- def mkMeta(truth: String): TestDesc = TestDesc(truth = truth, entity =
mkEntity(tokens = t1, t2))
+ def mkMeta(truth: String): TestDesc = TestDesc(truth = truth, entity =
mkEntity(tokens = t1t2))
test(
TestDesc(
truth = "# == 'a'",
- entity = mkEntity(id = "a", tokens = t1, t2)
+ entity = mkEntity(id = "a", tokens = t1t2)
),
TestDesc(
truth = "ent_id == 'a'",
- entity = mkEntity(id = "a", tokens = t1, t2)
+ entity = mkEntity(id = "a", tokens = t1t2)
),
TestDesc(
truth = "ent_index == 100",
@@ -48,12 +50,12 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
),
TestDesc(
truth = "ent_text == 'W1 w2'",
- entity = mkEntity(id = "a", tokens = t1, t2)
+ entity = mkEntity(id = "a", tokens = t1t2)
),
TestDesc(
truth = "ent_count == 1",
- entity = mkEntity(id = "a", tokens = t1, t2)
+ entity = mkEntity(id = "a", tokens = t1t2)
),
TestDesc(
truth = "ent_this() == ent_this()",
@@ -61,11 +63,11 @@ class NCIDLFunctionsEntity extends NCIDLFunctions:
),
TestDesc(
truth = "ent_groups() == list('g1', 'g2')",
- entity = mkEntity(id = "a", groups = Set("g1", "g2"), tokens =
t1, t2)
+ entity = mkEntity(id = "a", groups = Set("g1", "g2"), tokens =
t1t2)
),
TestDesc(
truth = "ent_groups() == list('a')",
- entity = mkEntity(id = "a", tokens = t1, t2)
+ entity = mkEntity(id = "a", tokens = t1t2)
)
)
}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
index 6b7929d8..abc14495 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIDLFunctionsMeta.scala
@@ -20,6 +20,7 @@ package org.apache.nlpcraft.internal.intent.compiler.functions
import org.apache.nlpcraft.*
import org.apache.nlpcraft.internal.intent.NCIDLContext
import org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.*
+import
org.apache.nlpcraft.internal.intent.compiler.functions.NCIDLFunctions.given
import org.apache.nlpcraft.nlp.util.NCTestToken
import java.util