This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-376
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-376 by this push:
new 530bec0 WIP.
530bec0 is described below
commit 530bec01fbeb56309dae462e6fb11cac3883dbec
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Jul 28 13:44:03 2021 +0300
WIP.
---
.../{NCStmLimitSpec.scala => NCLimitSpec.scala} | 18 +++++++++---------
.../{NCStmRelationSpec.scala => NCRelationSpec.scala} | 18 +++++++++---------
.../indexes/{NCStmSortSpec.scala => NCSortSpec.scala} | 18 +++++++++---------
...SpecModelAdapter.scala => NCSpecModelAdapter.scala} | 4 ++--
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmLimitSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCLimitSpec.scala
similarity index 75%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmLimitSpec.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCLimitSpec.scala
index 5feee96..8b9140f 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmLimitSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCLimitSpec.scala
@@ -18,7 +18,7 @@
package org.apache.nlpcraft.models.stm.indexes
import org.apache.nlpcraft.model.{NCIntent, NCIntentMatch, NCResult, _}
-import org.apache.nlpcraft.models.stm.indexes.NCStmSpecModelAdapter.mapper
+import org.apache.nlpcraft.models.stm.indexes.NCSpecModelAdapter.mapper
import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment}
import org.junit.jupiter.api.Test
@@ -26,14 +26,14 @@ import java.util.{List => JList}
import scala.jdk.CollectionConverters.ListHasAsScala
import scala.language.implicitConversions
-case class NCStmLimitSpecModelData(note: String, indexes: Seq[Int])
+case class NCLimitSpecModelData(note: String, indexes: Seq[Int])
-class NCStmLimitSpecModel extends NCStmSpecModelAdapter {
+class NCLimitSpecModel extends NCSpecModelAdapter {
@NCIntent("intent=limit term(limit)~{tok_id() == 'nlpcraft:limit'}
term(elem)~{has(tok_groups(), 'G')}")
private def onLimit(ctx: NCIntentMatch, @NCIntentTerm("limit") limit:
NCToken): NCResult =
NCResult.json(
mapper.writeValueAsString(
- NCStmLimitSpecModelData(
+ NCLimitSpecModelData(
note = limit.meta[String]("nlpcraft:limit:note"),
indexes =
limit.meta[JList[Int]]("nlpcraft:limit:indexes").asScala.toSeq
)
@@ -41,21 +41,21 @@ class NCStmLimitSpecModel extends NCStmSpecModelAdapter {
)
}
-@NCTestEnvironment(model = classOf[NCStmLimitSpecModel], startClient = true)
-class NCStmLimitSpec extends NCTestContext {
- private def extract(s: String): NCStmLimitSpecModelData =
mapper.readValue(s, classOf[NCStmLimitSpecModelData])
+@NCTestEnvironment(model = classOf[NCLimitSpecModel], startClient = true)
+class NCLimitSpec extends NCTestContext {
+ private def extract(s: String): NCLimitSpecModelData = mapper.readValue(s,
classOf[NCLimitSpecModelData])
@Test
private[stm] def test(): Unit = {
checkResult(
"top 23 a a",
extract,
- NCStmLimitSpecModelData(note = "A", indexes = Seq(1))
+ NCLimitSpecModelData(note = "A", indexes = Seq(1))
)
checkResult(
"test test b b",
extract,
- NCStmLimitSpecModelData(note = "B", indexes = Seq(2))
+ NCLimitSpecModelData(note = "B", indexes = Seq(2))
)
}
}
\ No newline at end of file
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmRelationSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCRelationSpec.scala
similarity index 74%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmRelationSpec.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCRelationSpec.scala
index 745a78a..c1d42c5 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmRelationSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCRelationSpec.scala
@@ -18,7 +18,7 @@
package org.apache.nlpcraft.models.stm.indexes
import org.apache.nlpcraft.model.{NCIntent, NCIntentMatch, NCResult, _}
-import org.apache.nlpcraft.models.stm.indexes.NCStmSpecModelAdapter.mapper
+import org.apache.nlpcraft.models.stm.indexes.NCSpecModelAdapter.mapper
import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment}
import org.junit.jupiter.api.Test
@@ -26,14 +26,14 @@ import java.util.{List => JList}
import scala.jdk.CollectionConverters.ListHasAsScala
import scala.language.implicitConversions
-case class NCStmRelationSpecModelData(note: String, indexes: Seq[Int])
+case class NCRelationSpecModelData(note: String, indexes: Seq[Int])
-class NCStmRelationSpecModel extends NCStmSpecModelAdapter {
+class NCRelationSpecModel extends NCSpecModelAdapter {
@NCIntent("intent=rel term(rel)~{tok_id() == 'nlpcraft:relation'}
term(elem)~{has(tok_groups(), 'G')}*")
private def onRelation(ctx: NCIntentMatch, @NCIntentTerm("rel") rel:
NCToken): NCResult =
NCResult.json(
mapper.writeValueAsString(
- NCStmLimitSpecModelData(
+ NCRelationSpecModelData(
note = rel.meta[String]("nlpcraft:relation:note"),
indexes =
rel.meta[JList[Int]]("nlpcraft:relation:indexes").asScala.toSeq
)
@@ -41,21 +41,21 @@ class NCStmRelationSpecModel extends NCStmSpecModelAdapter {
)
}
-@NCTestEnvironment(model = classOf[NCStmRelationSpecModel], startClient = true)
-class NCStmRelationSpec extends NCTestContext {
- private def extract(s: String): NCStmRelationSpecModelData =
mapper.readValue(s, classOf[NCStmRelationSpecModelData])
+@NCTestEnvironment(model = classOf[NCRelationSpecModel], startClient = true)
+class NCRelationSpec extends NCTestContext {
+ private def extract(s: String): NCRelationSpecModelData =
mapper.readValue(s, classOf[NCRelationSpecModelData])
@Test
private[stm] def test(): Unit = {
checkResult(
"compare a a and a a",
extract,
- NCStmRelationSpecModelData(note = "A", indexes = Seq(1, 3))
+ NCRelationSpecModelData(note = "A", indexes = Seq(1, 3))
)
checkResult(
"b b and b b",
extract,
- NCStmRelationSpecModelData(note = "B", indexes = Seq(0, 2))
+ NCRelationSpecModelData(note = "B", indexes = Seq(0, 2))
)
}
}
\ No newline at end of file
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSortSpec.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSortSpec.scala
similarity index 77%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSortSpec.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSortSpec.scala
index cb932cb..a33f0cb 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSortSpec.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSortSpec.scala
@@ -18,7 +18,7 @@
package org.apache.nlpcraft.models.stm.indexes
import org.apache.nlpcraft.model.{NCIntent, NCIntentMatch, NCResult, _}
-import org.apache.nlpcraft.models.stm.indexes.NCStmSpecModelAdapter.mapper
+import org.apache.nlpcraft.models.stm.indexes.NCSpecModelAdapter.mapper
import org.apache.nlpcraft.{NCTestContext, NCTestEnvironment}
import org.junit.jupiter.api.Test
@@ -26,19 +26,19 @@ import java.util.{List => JList}
import scala.jdk.CollectionConverters.ListHasAsScala
import scala.language.implicitConversions
-case class NCStmSortSpecModelData(
+case class NCSortSpecModelData(
subjnotes: Seq[String] = Seq.empty,
subjindexes: Seq[Int] = Seq.empty,
bynotes: Seq[String] = Seq.empty,
byindexes: Seq[Int] = Seq.empty
)
-class NCStmSortSpecModel extends NCStmSpecModelAdapter {
+class NCSortSpecModel extends NCSpecModelAdapter {
@NCIntent("intent=onBySort term(sort)~{tok_id() == 'nlpcraft:sort'}
term(elem)~{has(tok_groups(), 'G')}")
private def onBySort(ctx: NCIntentMatch, @NCIntentTerm("sort") sort:
NCToken): NCResult =
NCResult.json(
mapper.writeValueAsString(
- NCStmSortSpecModelData(
+ NCSortSpecModelData(
bynotes =
sort.meta[JList[String]]("nlpcraft:sort:bynotes").asScala.toSeq,
byindexes =
sort.meta[JList[Int]]("nlpcraft:sort:byindexes").asScala.toSeq
)
@@ -46,21 +46,21 @@ class NCStmSortSpecModel extends NCStmSpecModelAdapter {
)
}
-@NCTestEnvironment(model = classOf[NCStmSortSpecModel], startClient = true)
-class NCStmSortSpec extends NCTestContext {
- private def extract(s: String): NCStmSortSpecModelData =
mapper.readValue(s, classOf[NCStmSortSpecModelData])
+@NCTestEnvironment(model = classOf[NCSortSpecModel], startClient = true)
+class NCSortSpec extends NCTestContext {
+ private def extract(s: String): NCSortSpecModelData = mapper.readValue(s,
classOf[NCSortSpecModelData])
@Test
private[stm] def test(): Unit = {
checkResult(
"test test sort by a a",
extract,
- NCStmSortSpecModelData(bynotes = Seq("A"), byindexes = Seq(3))
+ NCSortSpecModelData(bynotes = Seq("A"), byindexes = Seq(3))
)
checkResult(
"test b b",
extract,
- NCStmSortSpecModelData(bynotes = Seq("B"), byindexes = Seq(1))
+ NCSortSpecModelData(bynotes = Seq("B"), byindexes = Seq(1))
)
}
}
\ No newline at end of file
diff --git
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSpecModelAdapter.scala
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSpecModelAdapter.scala
similarity index 92%
rename from
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSpecModelAdapter.scala
rename to
nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSpecModelAdapter.scala
index 133ab23..7d0c5de 100644
---
a/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCStmSpecModelAdapter.scala
+++
b/nlpcraft/src/test/scala/org/apache/nlpcraft/models/stm/indexes/NCSpecModelAdapter.scala
@@ -25,13 +25,13 @@ import java.util
import java.util.Collections
import scala.jdk.CollectionConverters.{SeqHasAsJava, SetHasAsJava}
-object NCStmSpecModelAdapter {
+object NCSpecModelAdapter {
val mapper = new ObjectMapper()
mapper.registerModule(new DefaultScalaModule())
}
-class NCStmSpecModelAdapter extends NCModelAdapter("nlpcraft.stm.idxs.test",
"STM Indexes Test Model", "1.0") {
+class NCSpecModelAdapter extends NCModelAdapter("nlpcraft.stm.idxs.test", "STM
Indexes Test Model", "1.0") {
override def getElements: util.Set[NCElement] =
Set(
mkElement("A", "G", "a a"),