This is an automated email from the ASF dual-hosted git repository. sergeykamov pushed a commit to branch NLPCRAFT-500 in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit b661edeb74246d09b716ecfd224cdced2271e4e7 Author: Sergey Kamov <[email protected]> AuthorDate: Thu Aug 25 13:20:29 2022 +0300 IDL fragments related fixes. --- .../intent/compiler/NCIDLFragmentsOverridingSpec.scala | 16 ++++++++-------- ...ingSpec.scala => NCIDLFragmentsOverridingSpec2.scala} | 12 ++++++------ .../intent/compiler/{imp1.idl => impl_level1.idl} | 0 .../intent/compiler/{imp2.idl => impl_level2.idl} | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala index 1940c2f6..dfe77b57 100644 --- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala +++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec.scala @@ -27,24 +27,24 @@ import org.junit.jupiter.api.Test import scala.util.Using class NCIDLFragmentsOverridingSpec: - @NCIntent("fragment=f term(x)~{# == 'x'}") + @NCIntent("fragment=f term(x)~{# == 'x1'}") class M extends NCTestModelAdapter: // Uses fragment defined on class level. @NCIntent("intent=i2 fragment(f)") - private def onX(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult("onX") + private def onX(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult(1) - // Overrides fragment defined on class level. - @NCIntent("fragment=f term(y)~{# == 'y'} intent=i1 fragment(f)") - private def onY(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult("onY") + // Overrides fragment defined on class level by its own. + @NCIntent("fragment=f term(y)~{# == 'x2'} intent=i1 fragment(f)") + private def onY(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult(2) override val getPipeline: NCPipeline = val pl = mkEnPipeline - pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("x"), TE("y")) + pl.entParsers += NCTestUtils.mkEnSemanticParser(TE("x1"), TE("x2")) pl @Test def test(): Unit = Using.resource(new NCModelClient(new M())) { client => - require(client.ask("x", "usr").getBody == "onX") - require(client.ask("y", "usr").getBody == "onY") + require(client.ask("x1", "usr").getBody == 1) + require(client.ask("x2", "usr").getBody == 2) } \ No newline at end of file diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLImportsOverridingSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala similarity index 87% rename from nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLImportsOverridingSpec.scala rename to nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala index 0d58e858..41d5adfa 100644 --- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLImportsOverridingSpec.scala +++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLFragmentsOverridingSpec2.scala @@ -26,19 +26,19 @@ import org.junit.jupiter.api.Test import scala.util.Using -class NCIDLImportsOverridingSpec: - @NCIntent("import('org/apache/nlpcraft/internal/intent/compiler/imp2.idl')") +class NCIDLFragmentsOverridingSpec2: + @NCIntent("import('org/apache/nlpcraft/internal/intent/compiler/impl_level2.idl')") class M extends NCTestModelAdapter: - // Uses fragment defined on imp2.idl, which overrides imp1.idl. + // Uses fragment, defined on impl_level2.idl, which overrides impl_level1.idl. @NCIntent("intent=i2 fragment(f)") private def on2(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult(2) - // Uses own fragment, which which overrides all. + // Uses own fragment, which overrides all. @NCIntent("fragment=f term(z)~{# == 'x3'} intent=i3 fragment(f)") private def on3(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult(3) - // Uses initial fragment version, defined in imp1.idl. - @NCIntent("import('org/apache/nlpcraft/internal/intent/compiler/imp1.idl')") + // Uses initial fragment version (with intent), defined in impl_level1.idl. + @NCIntent("import('org/apache/nlpcraft/internal/intent/compiler/impl_level1.idl')") @NCIntentRef("i1") private def on1(ctx: NCContext, im: NCIntentMatch): NCResult = NCResult(1) diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/imp1.idl b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/impl_level1.idl similarity index 100% rename from nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/imp1.idl rename to nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/impl_level1.idl diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/imp2.idl b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/impl_level2.idl similarity index 92% rename from nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/imp2.idl rename to nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/impl_level2.idl index f92ba03f..fe5a0139 100644 --- a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/imp2.idl +++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/impl_level2.idl @@ -19,6 +19,6 @@ // Test content. // ============================ -import('org/apache/nlpcraft/internal/intent/compiler/imp1.idl') +import('org/apache/nlpcraft/internal/intent/compiler/impl_level1.idl') // Overrides fragment. fragment=f term={# == 'x2'}
