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 d62eb17 WIP.
d62eb17 is described below
commit d62eb1761d0410896c63167fa0af9d30759cb12b
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Mon Mar 1 21:26:16 2021 -0800
WIP.
---
.../intent/impl/ver2/NCIntentDslCompiler.scala | 1 +
.../impl/ver2/NCIntentDslFragmentCache.scala | 8 +++++-
.../model/intent/dsl/NCIntentDslCompilerSpec.scala | 31 +++++++++++++++++++++-
3 files changed, 38 insertions(+), 2 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 6943f1c..97a95fd 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
@@ -236,6 +236,7 @@ object NCIntentDslCompiler extends LazyLogging {
// Reset term vars.
setMinMax(1, 1)
+ termId = null
termInstrs.clear()
refClsName = None
refMtdName = None
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslFragmentCache.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslFragmentCache.scala
index 158e972..c240e84 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslFragmentCache.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/ver2/NCIntentDslFragmentCache.scala
@@ -34,7 +34,13 @@ object NCIntentDslFragmentCache {
* @param frag
*/
def add(mdlId: String, frag: NCDslFragment): Unit =
- cache.getOrElse(mdlId, mutable.HashMap.empty[String, NCDslFragment])
+= (frag.id → frag)
+ cache.getOrElse(mdlId, {
+ val m = mutable.HashMap.empty[String, NCDslFragment]
+
+ cache += mdlId → m
+
+ m
+ }) += (frag.id → frag)
/**
*
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 5b90de5..608536e 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
@@ -36,7 +36,7 @@ class NCIntentDslCompilerSpec {
assert(true)
}
catch {
- case _: Exception ⇒ assert(false)
+ case e: Exception ⇒ assert(false, e)
}
/**
@@ -72,6 +72,35 @@ class NCIntentDslCompilerSpec {
| term(t1)={has(json("{'a': true, 'b\'2': {'arr': [1, 2,
3]}}"), map("موسكو\"", 'v1\'v1', "k2", "v2"))}
|""".stripMargin
)
+ checkOk(
+ """
+ |fragment=f1
+ | term(ft1)={2==2}
+ | term~/class#method/
+ |
+ |intent=i1
+ | flow="a[^0-9]b"
+ | term(t1)={has(json("{'a': true, 'b\'2': {'arr': [1, 2,
3]}}"), map("موسكو\"", 'v1\'v1', "k2", "v2"))}
+ | fragment(f1, {'a': true, 'b': ["s1", "s2"]})
+ |""".stripMargin
+ )
+ checkOk(
+ """
+ |fragment=f21
+ | term(f21_t1)={2==2}
+ | term~/class#method/
+ |
+ |fragment=f22
+ | term(f22_t1)={2==2}
+ | fragment(f21)
+ | term~/class#method/
+ |
+ |intent=i1
+ | flow="a[^0-9]b"
+ | term(t1)={has(json("{'a': true, 'b\'2': {'arr': [1, 2,
3]}}"), map("موسكو\"", 'v1\'v1', "k2", "v2"))}
+ | fragment(f21, {'a': true, 'b': ["s1", "s2"]})
+ |""".stripMargin
+ )
}
@Test