This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-206
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-206 by this push:
     new 8c10631  WIP.
8c10631 is described below

commit 8c10631de4fbefcb8c67af08c54c21508af475f6
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Tue Mar 2 00:25:30 2021 -0800

    WIP.
---
 .../intent/impl/ver2/NCIntentDslCompiler.scala     |  2 +-
 .../model/intent/dsl/NCIntentDslCompilerSpec.scala | 30 +++++++++++++++++++---
 .../model/intent/dsl/{test.nc => test_ok.nc}       |  6 ++---
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
index 37f0a3d..75a10d9 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslCompiler.scala
@@ -440,7 +440,7 @@ object NCIntentDslCompiler extends LazyLogging {
       * @return
       */
     @throws[NCE]
-    def compileFile(
+    def compilePath(
         filePath: Path,
         mdlId: String
     ): Set[NCDslIntent] = antlr4(U.readFile(filePath.toFile).mkString("\n"), 
mdlId, filePath.getFileName.toString)
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCIntentDslCompilerSpec.scala
 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCIntentDslCompilerSpec.scala
index 1f13305..c5f71af 100644
--- 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCIntentDslCompilerSpec.scala
+++ 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCIntentDslCompilerSpec.scala
@@ -21,6 +21,8 @@ import org.apache.nlpcraft.common._
 import org.apache.nlpcraft.model.intent.impl.ver2.{NCIntentDslCompiler, 
NCIntentDslFragmentCache}
 import org.junit.jupiter.api.Test
 
+import java.nio.file.{Path, Paths}
+
 /**
  * Tests for DSL compiler.
  */
@@ -40,6 +42,20 @@ class NCIntentDslCompilerSpec {
         catch {
             case e: Exception ⇒ assert(false, e)
         }
+    
+    /**
+      *
+      * @param path
+      */
+    private def checkPathCompileOk(path: Path): Unit =
+        try {
+            NCIntentDslCompiler.compilePath(path, MODEL_ID)
+            
+            assert(true)
+        }
+        catch {
+            case e: Exception ⇒ assert(false, e)
+        }
 
     /**
      *
@@ -55,10 +71,18 @@ class NCIntentDslCompilerSpec {
                 println(e.getMessage)
                 assert(true)
         }
-
+    
+    @Test
+    @throws[NCException]
+    def testPathCompileOk(): Unit = {
+        NCIntentDslFragmentCache.clear(MODEL_ID)
+        
+        
checkPathCompileOk(Paths.get(classOf[NCIntentDslCompilerSpec].getResource("test_ok.nc").toURI))
+    }
+    
     @Test
     @throws[NCException]
-    def testOk(): Unit = {
+    def testInlineCompileOk(): Unit = {
         NCIntentDslFragmentCache.clear(MODEL_ID)
         
         checkCompileOk(
@@ -109,7 +133,7 @@ class NCIntentDslCompilerSpec {
 
     @Test
     @throws[NCException]
-    def testFail(): Unit = {
+    def testInlineCompileFail(): Unit = {
         NCIntentDslFragmentCache.clear(MODEL_ID)
         
         checkCompileError(
diff --git 
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test.nc 
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test_ok.nc
similarity index 92%
rename from nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test.nc
rename to 
nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test_ok.nc
index 5f8ad98..0042488 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test.nc
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/test_ok.nc
@@ -20,13 +20,13 @@
 // ============================
 
 // Re-usable predicate #1.
-predicate=p1
+fragment=p1
     term={1 == 2}
 
 // Intent #1.
 intent=i1
     flow=/org.package#method1/ // User-code flow predicate.
-    predicate(p1, {'a': true, 'b': {'Москва': [1, 2, 3]}}) /*  
Macro-expansion. */
+    fragment(p1, {'a': true, 'b': {'Москва': [1, 2, 3]}}) /*  Macro-expansion. 
*/
     term~{length("some text") > 0} // Normal term.
 
 // Intent #2.
@@ -35,7 +35,7 @@ intent=i2
     meta={'a': true, 'b': {'Москва': [1, 2, 3]}}
     term(t1)={2 == 2 && size(id()) != -25}
 
-intent=i1
+intent=i3
     flow="a[^0-9]b"
     term(t1)={
         has(

Reply via email to