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 33aa4de WIP.
33aa4de is described below
commit 33aa4de60a9c26f4d59d3e22e5484b03be90497d
Author: Aaron Radzinski <[email protected]>
AuthorDate: Mon Feb 15 20:37:35 2021 -0800
WIP.
---
.../model/intent/impl/ver2/NCIntentDslCompiler.scala | 13 +++++++------
.../nlpcraft/model/intent/dsl/NCDslCompilerSpec.scala | 11 +++++------
2 files changed, 12 insertions(+), 12 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 b2598a4..e562021 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
@@ -17,6 +17,7 @@
package org.apache.nlpcraft.model.intent.impl.ver2
+import com.google.gson.reflect.TypeToken
import com.typesafe.scalalogging.LazyLogging
import org.antlr.v4.runtime._
import org.antlr.v4.runtime.tree.ParseTreeWalker
@@ -26,7 +27,7 @@ import org.apache.nlpcraft.model.NCToken
import org.apache.nlpcraft.model.intent.impl.antlr4._
import org.apache.nlpcraft.model.intent.utils.ver2._
-import scala.collection.immutable.HashMap
+import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import java.lang.{Double ⇒ JDouble, IllegalArgumentException ⇒ IAE, Long ⇒
JLong}
@@ -591,6 +592,7 @@ object NCIntentDslCompiler extends LazyLogging {
case "take" ⇒
case "drop" ⇒
case "size" ⇒
+ case "length" ⇒
case "reverse" ⇒
case "is_empty" ⇒
case "non_empty" ⇒
@@ -653,7 +655,7 @@ object NCIntentDslCompiler extends LazyLogging {
}
override def exitMetaDecl(ctx: NCIntentDslParser.MetaDeclContext):
Unit = {
- meta = U.jsonToObject(ctx.jsonObj().getText,
classOf[HashMap[String, Any]])
+ meta = U.jsonToObject(ctx.jsonObj().getText,
classOf[java.util.HashMap[String, Any]]).asScala.toMap
}
override def exitOrderedDecl(ctx:
NCIntentDslParser.OrderedDeclContext): Unit = {
@@ -696,6 +698,8 @@ object NCIntentDslCompiler extends LazyLogging {
val pred =
if (termMtdName != null) { // User-code defined term.
(tok: NCToken, ctx: NCDslTermContext) ⇒ {
+ // TODO.
+
(true, true)
}
}
@@ -797,10 +801,7 @@ object NCIntentDslCompiler extends LazyLogging {
*/
def compile(
dsl: String,
- mdlId: String,
- reqMeta: ScalaMeta,
- usrMeta: ScalaMeta,
- compMeta: ScalaMeta
+ mdlId: String
): NCDslIntent = {
require(dsl != null)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslCompilerSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslCompilerSpec.scala
index 021c2fb..dba5baa 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslCompilerSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/intent/dsl/NCDslCompilerSpec.scala
@@ -28,13 +28,12 @@ class NCDslCompilerSpec {
@Test
@throws[NCException]
def test(): Unit = {
- NCIntentDslCompiler.compile(
+ val intent = NCIntentDslCompiler.compile(
"""
- |intent=i1 meta={'a': true} term={2 == 2 && size(id()) != -25}
- |""".stripMargin, "mdl.id",
- Map.empty[String, AnyRef],
- Map.empty[String, AnyRef],
- Map.empty[String, AnyRef]
+ |intent=i1 flow="a[^0-9]b" meta={'a': true, 'b': {'arr': [1, 2,
3]}} term(t1)={2 == 2 && size(id()) != -25}
+ |""".stripMargin, "mdl.id"
)
+
+ println(intent)
}
}