You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by ar...@apache.org on 2021/09/10 17:54:49 UTC
[incubator-nlpcraft] branch NLPCRAFT-434 updated: Code review.
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-434
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-434 by this push:
new 370b817 Code review.
370b817 is described below
commit 370b8171ed4b686dae331e0b39a2346db4710219
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Fri Sep 10 10:54:25 2021 -0700
Code review.
---
.../{NCElementDefinition.java => NCAddElement.java} | 11 +++++++----
...CElementDefinition2.java => NCAddElementClass.java} | 11 +++++++----
.../nlpcraft/probe/mgrs/deploy/NCDeployManager.scala | 12 ++++++------
.../probe/mgrs/deploy1/NCElementAnnotationsSpec.scala | 18 +++++++++---------
.../mgrs/deploy1/pack/NCElementAnnotations2.scala | 8 ++++----
5 files changed, 33 insertions(+), 27 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
similarity index 89%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition.java
rename to nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
index dff9ae7..b6aadfd 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
@@ -30,8 +30,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(value=RUNTIME)
@Target(value=METHOD)
-@Repeatable(NCElementDefinition.NCIntentRefList.class)
-public @interface NCElementDefinition {
+@Repeatable(NCAddElement.NCAddElementList.class)
+public @interface NCAddElement {
/**
* ID of the intent term.
*
@@ -39,10 +39,13 @@ public @interface NCElementDefinition {
*/
String value();
+ /**
+ *
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(value=METHOD)
@Documented
- @interface NCIntentRefList {
- NCElementDefinition[] value();
+ @interface NCAddElementList {
+ NCAddElement[] value();
}
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition2.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElementClass.java
similarity index 87%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition2.java
rename to nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElementClass.java
index d7a6b5d..fa0d345 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElementDefinition2.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElementClass.java
@@ -30,8 +30,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Documented
@Retention(value=RUNTIME)
@Target(value=METHOD)
-@Repeatable(NCElementDefinition2.NCIntentRefList.class)
-public @interface NCElementDefinition2 {
+@Repeatable(NCAddElementClass.NCAddElementClassList.class)
+public @interface NCAddElementClass {
/**
* ID of the intent term.
*
@@ -39,10 +39,13 @@ public @interface NCElementDefinition2 {
*/
Class<?> value();
+ /**
+ *
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(value=METHOD)
@Documented
- @interface NCIntentRefList {
- NCElementDefinition2[] value();
+ @interface NCAddElementClassList {
+ NCAddElementClass[] value();
}
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index de45a18..490b62d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -68,8 +68,8 @@ object NCDeployManager extends NCService {
private final val CLS_SAMPLE_REF = classOf[NCIntentSampleRef]
private final val CLS_MDL_CLS_REF = classOf[NCModelAddClasses]
private final val CLS_MDL_PKGS_REF = classOf[NCModelAddPackage]
- private final val CLS_ELEM_DEF = classOf[NCElementDefinition]
- private final val CLS_ELEM_DEF_CLASS = classOf[NCElementDefinition2]
+ private final val CLS_ELEM_DEF = classOf[NCAddElement]
+ private final val CLS_ELEM_DEF_CLASS = classOf[NCAddElementClass]
// Java and scala lists.
private final val CLS_SCALA_SEQ = classOf[Seq[_]]
@@ -1622,9 +1622,9 @@ object NCDeployManager extends NCService {
val elems = mutable.HashSet.empty[NCElement]
def scan(claxx: Class[_]): Unit = {
- val allClassAnns = mutable.ArrayBuffer.empty[NCElementDefinition]
+ val allClassAnns = mutable.ArrayBuffer.empty[NCAddElement]
- def add(anns: Array[NCElementDefinition]): Unit = if (anns != null) allClassAnns ++= anns.toSeq
+ def add(anns: Array[NCAddElement]): Unit = if (anns != null) allClassAnns ++= anns.toSeq
// Class.
add(claxx.getAnnotationsByType(CLS_ELEM_DEF))
@@ -1693,9 +1693,9 @@ object NCDeployManager extends NCService {
elems += elem
- val allClassDefAnns = mutable.ArrayBuffer.empty[NCElementDefinition2]
+ val allClassDefAnns = mutable.ArrayBuffer.empty[NCAddElementClass]
- def addClass(anns: Array[NCElementDefinition2]): Unit = if (anns != null) allClassDefAnns ++= anns.toSeq
+ def addClass(anns: Array[NCAddElementClass]): Unit = if (anns != null) allClassDefAnns ++= anns.toSeq
addClass(claxx.getAnnotationsByType(CLS_ELEM_DEF_CLASS))
getAllMethods(claxx).foreach(m => addClass(m.getAnnotationsByType(CLS_ELEM_DEF_CLASS)))
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/NCElementAnnotationsSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/NCElementAnnotationsSpec.scala
index 3c92112..88ff99f 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/NCElementAnnotationsSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/NCElementAnnotationsSpec.scala
@@ -17,17 +17,17 @@
package org.apache.nlpcraft.probe.mgrs.deploy1
-import org.apache.nlpcraft.model.{NCElement, NCElementDefinition, NCElementDefinition2, NCIntent, NCModelAdapter, NCModelAddClasses, NCModelAddPackage, NCResult}
+import org.apache.nlpcraft.model.{NCElement, NCAddElement, NCAddElementClass, NCIntent, NCModelAdapter, NCModelAddClasses, NCModelAddPackage, NCResult}
import org.apache.nlpcraft.{NCTestContext, NCTestElement, NCTestEnvironment}
import org.junit.jupiter.api.Test
import java.util
-@NCElementDefinition("""{ "id": "e5" }""")
-@NCElementDefinition("""{ "id": "e6", "synonyms": ["e66"] }""")
+@NCAddElement("""{ "id": "e5" }""")
+@NCAddElement("""{ "id": "e6", "synonyms": ["e66"] }""")
class NCElementAnnotations1 {
- @NCElementDefinition("""{ "id": "e7" }""")
- @NCElementDefinition("""{ "id": "e8" }""")
+ @NCAddElement("""{ "id": "e7" }""")
+ @NCAddElement("""{ "id": "e8" }""")
def x(): Unit = ()
}
@@ -39,15 +39,15 @@ class NCElementAnn1 extends NCElement {
*/
@NCModelAddClasses(Array{classOf[NCElementAnnotations1]})
@NCModelAddPackage(Array("org.apache.nlpcraft.probe.mgrs.deploy1.pack"))
-@NCElementDefinition("""{ "id": "e3" }""")
-@NCElementDefinition("""{ "id": "e4" }""")
+@NCAddElement("""{ "id": "e3" }""")
+@NCAddElement("""{ "id": "e4" }""")
class NCElementAnnotationsSpecModel extends NCModelAdapter("nlpcraft.intents.idl.test", "IDL Test Model", "1.0") {
override def getElements: util.Set[NCElement] = Set(NCTestElement("e1"))
@NCIntent("intent=onE1 term={# == 'e1'}")
def onE1(): NCResult = NCResult.text("OK")
- @NCElementDefinition("""{ "id": "e2" }""")
+ @NCAddElement("""{ "id": "e2" }""")
@NCIntent("intent=onE2 term={# == 'e2'}")
def onE2(): NCResult = NCResult.text("OK")
@@ -78,7 +78,7 @@ class NCElementAnnotationsSpecModel extends NCModelAdapter("nlpcraft.intents.idl
@NCIntent("intent=onE11 term={# == 'e11'}")
def onE11(): NCResult = NCResult.text("OK")
- @NCElementDefinition2(classOf[NCElementAnn1])
+ @NCAddElementClass(classOf[NCElementAnn1])
@NCIntent("intent=onE12 term={# == 'e12'}")
def onE12(): NCResult = NCResult.text("OK")
}
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/pack/NCElementAnnotations2.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/pack/NCElementAnnotations2.scala
index 26f5d6f..a3e3d0d 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/pack/NCElementAnnotations2.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/probe/mgrs/deploy1/pack/NCElementAnnotations2.scala
@@ -17,10 +17,10 @@
package org.apache.nlpcraft.probe.mgrs.deploy1.pack
-import org.apache.nlpcraft.model.NCElementDefinition
+import org.apache.nlpcraft.model.NCAddElement
-@NCElementDefinition("""{ "id": "e9" }""")
-@NCElementDefinition(
+@NCAddElement("""{ "id": "e9" }""")
+@NCAddElement(
"""---
id: "e10"
synonyms:
@@ -29,6 +29,6 @@ import org.apache.nlpcraft.model.NCElementDefinition
"""
)
class NCElementAnnotations2 {
- @NCElementDefinition("""{ "id": "e11" }""")
+ @NCAddElement("""{ "id": "e11" }""")
def x(): Unit = ()
}
\ No newline at end of file