This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-474
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-474 by this push:
new cd389ae WIP
cd389ae is described below
commit cd389ae255014eff34359c142ce5e20c041233a8
Author: Aaron Radzinski <[email protected]>
AuthorDate: Tue Jan 25 11:26:48 2022 -0800
WIP
---
.../nlpcraft/internal/antlr4/NCCompilerUtils.scala | 4 ++--
.../internal/intent/compiler/NCIDLCompiler.scala | 2 +-
.../internal/intent/compiler/NCIdlCompilerSpec.scala | 18 +++++++-----------
.../intent/compiler/functions/NCIdlFunctionsDate.scala | 9 +++------
.../nlpcraft/internal/intent/compiler/test_ok.idl | 17 ++++++-----------
5 files changed, 19 insertions(+), 31 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
index 876efd6..540bd0f 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/antlr4/NCCompilerUtils.scala
@@ -36,9 +36,9 @@ object NCCompilerUtils:
val in0 = in.strip()
val pos = Math.max(0, charPos0)
val dash = "-" * in0.length
- var ptrStr = s"${dash.substring(0, pos)}\"^\""
- if pos < dash.length - 1 then ptrStr = s"$ptrStr~${dash.substring(pos
+ 2)}"
+ var ptrStr = s"${dash.substring(0, pos)}^"
+ if pos < dash.length - 1 then ptrStr = s"$ptrStr${dash.substring(pos +
1)}"
else ptrStr = s"$ptrStr${dash.substring(pos + 1)}"
val origStr = s"${in0.substring(0,
pos)}${in0.charAt(pos)}${in0.substring(pos + 1)}"
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
index 8515f39..c23d176 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/compiler/NCIDLCompiler.scala
@@ -364,7 +364,7 @@ object NCIDLCompiler extends LazyLogging:
s" |-- Model ID: ${mdlCfg.getId}\n" +
s" |-- Model origin: ${mdlCfg.getOrigin}\n" +
s" |-- Intent origin: $origin\n" +
- s" |--<\n" +
+ s" |--\n" +
s" |-- Line: ${hold.origStr}\n" +
s" +-- Error: ${hold.ptrStr}"
}
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIdlCompilerSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIdlCompilerSpec.scala
index abca683..93595d2 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIdlCompilerSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/NCIdlCompilerSpec.scala
@@ -34,10 +34,8 @@ class NCIdlCompilerSpec:
private def checkCompileOk(idl: String): Unit =
try
NCIDLCompiler.compile(idl, CFG, MODEL_ID)
-
assert(true)
- catch
- case e: Exception => assert(assertion = false, e)
+ catch case e: Exception => assert(assertion = false, e)
/**
*
@@ -46,7 +44,6 @@ class NCIdlCompilerSpec:
private def checkCompileError(txt: String): Unit =
try
NCIDLCompiler.compile(txt, CFG, MODEL_ID)
-
assert(false)
catch
case e: NCException =>
@@ -83,7 +80,7 @@ class NCIdlCompilerSpec:
|// Some comments.
|fragment=f1
| term(ft1)={2==2} /* Term block comment. */
- | term~/class#method/
+ | term~{# == "1"}
|/*
| * +=====================+
| * | block comments......|
@@ -93,8 +90,7 @@ class NCIdlCompilerSpec:
| options={
| 'ordered': false,
| 'unused_free_words': true,
- | 'unused_sys_toks': true,
- | 'unused_usr_toks': false,
+ | 'unused_entities': true,
| 'allow_stm_only': false
| }
| flow="a[^0-9]b" // Flow comment.
@@ -106,12 +102,12 @@ class NCIdlCompilerSpec:
"""
|fragment=f21
| term(f21_t1)={2==2}
- | term~/class#method/
+ | term~{# == "1"}
|
|fragment=f22
| term(f22_t1)={2==2_000_000.23}
| fragment(f21)
- | term~/class#method/
+ | term~{# == "1"}
|
|intent=i1
| options={}
@@ -273,7 +269,7 @@ class NCIdlCompilerSpec:
"""
|fragment=f1
| term(t1)={2==2}
- | term~/class#method/
+ | term~{# == "1"}
|
|intent=i1
| flow="a[^0-9]b"
@@ -286,7 +282,7 @@ class NCIdlCompilerSpec:
|fragment=f111
| options={'ordered': 1}
| term(t1)={2==2}
- | term~/class#method/
+ | term~{# == "1"}
|
|intent=i1
| flow="a[^0-9]b"
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIdlFunctionsDate.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIdlFunctionsDate.scala
index 35f4c37..6328fd6 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIdlFunctionsDate.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/functions/NCIdlFunctionsDate.scala
@@ -53,9 +53,6 @@ class NCIdlFunctionsDate extends NCIdlFunctions:
s"now() - ${NCUtils.now()} < 5000"
)
- try
- test0()
- catch
- case _: AssertionError =>
- // Some field more than `second` can be changed. One more
attempt.
- test0()
+ try test0()
+ // Some field more than `second` can be changed. One more attempt.
+ catch case _: AssertionError => test0()
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/test_ok.idl
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/test_ok.idl
index fdb2e83..a033a88 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/test_ok.idl
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/internal/intent/compiler/test_ok.idl
@@ -21,19 +21,17 @@
// Re-usable predicate #1.
fragment=p1
- term={tok_id(tok_find_part(tok_this(), "alias")) == 2}
+ term={ent_id == 2}
term={meta_frag('a') && has_any(get(meta_frag('b'), 'Москва'), list(1, 2))}
- term(userDefined)=/org.apache.MyShit#myMethod/
+ term(alias)={mdl_id == "test.mdl.id"}
-// Intent #1.
intent=i1
- flow=/org.package#method1/ // User-code flow predicate.
- fragment(p1, {'a': true, 'b': {'Москва': [1, 2, 3]}}) /* Macro-expansion.
*/
- term~{length("some text") > 0} // Normal term.
+ flow="a[^0-9]b"
+ fragment(p1, {'a': true, 'b': {'Москва': [1, 2, 3]}})
+ term~{length("some text") > 0}
term={has_all(list(1, 2, 3, 4, 5), list(3, 5))}
term={if(2==2, "string", list(1, 2, 3))}
-// Intent #2.
intent=i2
flow="a[^0-9]b"
meta={'a': 42, 'b': {'Москва': [1, 2, 3]}}
@@ -57,8 +55,6 @@ intent=i3
)
}
-intent=i4 flow=/#flowModelMethod/ term(t1)=/#termModelMethod/
-
intent=i5
flow="a[^0-9]b"
meta={'a': 42, 'b': {'Москва': [1, 2, 3]}}
@@ -71,8 +67,7 @@ intent=i5
}
intent=i6
- flow=/#flowModelMethod/
- term(t1)=/org.mypackage.MyClass#termMethod/
+ term(t1)={# == "1"}
term(t2)={
@x = 2
@xx = ((@x * @x) / 2) * 3