This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-492
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-492 by this push:
new f2f251f WIP.
f2f251f is described below
commit f2f251f48c8aad3d2ceae79460651c4c1feeac8c
Author: Sergey Kamov <[email protected]>
AuthorDate: Sun Apr 3 16:12:37 2022 +0300
WIP.
---
.../org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
index 255d53c..5a309b0 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/nlp/NCEntityMapperSpec.scala
@@ -33,7 +33,7 @@ import scala.jdk.CollectionConverters.*
*
*/
class NCEntityMapperSpec:
- private case class SummatorMapper(ids: String*) extends NCEntityMapper:
+ private case class Combiner(ids: String*) extends NCEntityMapper:
override def convert(req: NCRequest, entities: JList[NCEntity], toks:
JList[NCToken]): JList[NCEntity] =
val es = entities.asScala
val replaced = es.filter(p => ids.contains(p.getId))
@@ -46,7 +46,8 @@ class NCEntityMapperSpec:
override val getRequestId: String = req.getRequestId
override val getId: String = ids.mkString
- (es.filter(e => !replaced.contains(e)) :+
newEntity).sortBy(_.getTokens.asScala.head.getIndex).asJava
+ es --= replaced
+ (es :+
newEntity).sortBy(_.getTokens.asScala.head.getIndex).asJava
private val mdl = new NCTestModelAdapter:
import NCSemanticTestElement as TE
@@ -57,18 +58,18 @@ class NCEntityMapperSpec:
pl.getEntityParsers.add(NCTestUtils.mkEnSemanticParser(TE("a"),
TE("b"), TE("c"), TE("d")))
// Replaces [a, b] -> [ab]
- ms.add(SummatorMapper("a", "b"))
+ ms.add(Combiner("a", "b"))
// Replaces [c, d] -> [cd]
- ms.add(SummatorMapper("c", "d"))
+ ms.add(Combiner("c", "d"))
// Replaces [ab, cd] -> [abcd]
- ms.add(SummatorMapper("ab", "cd"))
+ ms.add(Combiner("ab", "cd"))
pl
- @NCIntent("intent=abcd term(e)={# == 'abcd'}")
- def onMatch(@NCIntentTerm("e") e: NCEntity): NCResult = new
NCResult("OK", NCResultType.ASK_RESULT)
+ @NCIntent("intent=abcd term(abcd)={# == 'abcd'}")
+ def onMatch(@NCIntentTerm("abcd") abcd: NCEntity): NCResult = new
NCResult("OK", NCResultType.ASK_RESULT)
@Test
- def test(): Unit = Using.resource(new NCModelClient(mdl)) {
- client => require(client.ask("a b c d", null, "userId").getIntentId ==
"abcd")
+ def test(): Unit = Using.resource(new NCModelClient(mdl)) { client =>
+ require(client.ask("a b c d", null, "userId").getIntentId == "abcd")
}