This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master-model
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master-model by this push:
new 54cb5d2 WIP.
54cb5d2 is described below
commit 54cb5d2894534e241c39b402118eb09486e84cd7
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Oct 7 23:02:36 2021 +0300
WIP.
---
.../org/apache/nlpcraft/model/NCModelConfig.java | 8 +++++--
.../nlpcraft/model/builders/NCIntentsBuilder.java | 28 ----------------------
.../model/builders/NCIntentsSamplesBuilder.java | 23 ------------------
.../model/builders/NCModelConfigBuilder.java | 8 +++++--
.../model/builders/NCMultiElementsBuilder.java | 9 +++++++
.../java/org/apache/nlpcraft/model/NCSpec.java | 26 +++++++-------------
6 files changed, 30 insertions(+), 72 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
index 1505a0d..667b7fc 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
@@ -215,11 +215,15 @@ public interface NCModelConfig extends NCMetadata {
List<NCElement> getElements();
- default Map<String, Method> getIntents() {
+ // model class by default + for methods of given instances.
+ // Scanned for NCIntent, NCIntentRef, NCIntentSample, NCIntentSampleRef
+ default List<Object> getIntentsObjects() {
return null;
}
- default Map<String, List<List<String>>> getIntentsSamples() {
+ // model class by default + for static methods of given classes.
+ // Scanned for NCIntent, NCIntentRef, NCIntentSample, NCIntentSampleRef
+ default List<Class<?>> getIntentsClasses() {
return null;
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsBuilder.java
deleted file mode 100644
index 2179e85..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsBuilder.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.apache.nlpcraft.model.builders;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-public class NCIntentsBuilder {
- public NCIntentsBuilder withFiles(File... files) {
- return null;
- }
- public NCIntentsBuilder withUrls(URL... urls) {
- return null;
- }
- public NCIntentsBuilder withClasses(Class<?> ... classes) {
- return null;
- }
- public NCIntentsBuilder witObjects(Objects... objs) {
- return null;
- }
-
- public Map<String, Method> getIntents() {
- // TODO: implement.
- return null;
- }
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsSamplesBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsSamplesBuilder.java
deleted file mode 100644
index f0f7f09..0000000
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCIntentsSamplesBuilder.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package org.apache.nlpcraft.model.builders;
-
-import java.io.File;
-import java.net.URL;
-import java.util.List;
-import java.util.Map;
-
-public class NCIntentsSamplesBuilder {
- public NCIntentsSamplesBuilder withFiles(Map<String, File> files) {
- return null;
- }
- public NCIntentsSamplesBuilder withUrls(Map<String, File> urls) {
- return null;
- }
- public NCIntentsSamplesBuilder withClasses(Class<?> ... classes) {
- return null;
- }
-
- public Map<String, List<List<String>>> getSamples() {
- // TODO: implement.
- return null;
- }
-}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCModelConfigBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCModelConfigBuilder.java
index e0727bc..f0cca97 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCModelConfigBuilder.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCModelConfigBuilder.java
@@ -117,11 +117,15 @@ public class NCModelConfigBuilder {
return null;
}
- public NCModelConfigBuilder withIntents(Map<String, Method> intents) {
+ // model class by default + for static methods of given classes.
+ // Scanned for NCIntent, NCIntentRef, NCIntentSample, NCIntentSampleRef
+ public NCModelConfigBuilder withIntentsClasses(List<Class<?>> classes) {
return null;
}
- public NCModelConfigBuilder withIntentsSamples(Map<String,
List<List<String>>> samples) {
+ // model class by default + for methods of given instances.
+ // Scanned for NCIntent, NCIntentRef, NCIntentSample, NCIntentSampleRef
+ public NCModelConfigBuilder withIntentsObjects(List<Object> objs) {
return null;
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCMultiElementsBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCMultiElementsBuilder.java
index d561b3b..9bf822e 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCMultiElementsBuilder.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/builders/NCMultiElementsBuilder.java
@@ -9,15 +9,24 @@ import java.util.Map;
import java.io.File;
public class NCMultiElementsBuilder {
+ // Reads YSON/YAML
public NCMultiElementsBuilder withFiles(File... files) {
return null;
}
+ // Reads YSON/YAML
public NCMultiElementsBuilder withUrls(URL... url) {
return null;
}
+
+ // Reads NCAddElement annotations from class and methods
public NCMultiElementsBuilder withClasses(Class<?>... classes) {
return null;
}
+ // Reads NCAddElement annotations from class and methods
+ public NCMultiElementsBuilder withObjects(Object... objs) {
+ return null;
+ }
+
public NCMultiElementsBuilder withLoaders(Map<String, NCValueLoader>
loaders) {
return null;
}
diff --git a/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
b/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
index 85f0285..e8d99f6 100644
--- a/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
+++ b/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
@@ -2,11 +2,9 @@ package org.apache.nlpcraft.model;
import org.apache.nlpcraft.model.annotations.NCIntentRef;
import org.apache.nlpcraft.model.builders.NCSingleElementBuilder;
-import org.apache.nlpcraft.model.builders.NCIntentsSamplesBuilder;
import org.apache.nlpcraft.model.builders.NCModelConfigBuilder;
import org.apache.nlpcraft.model.builders.NCModelBuilder;
import org.apache.nlpcraft.model.builders.NCMultiElementsBuilder;
-import org.apache.nlpcraft.model.builders.NCIntentsBuilder;
import org.junit.jupiter.api.Test;
import java.util.Collections;
@@ -17,6 +15,12 @@ import java.util.Set;
import java.util.function.BiFunction;
public class NCSpec {
+ private class SomeClassWithIntents {
+ @NCIntentRef("remove:waypoint")
+ public void x() {
+
+ }
+ }
private static <T> Set<T> asSet(T s) {
return Collections.singleton(s);
}
@@ -55,27 +59,15 @@ public class NCSpec {
elements.add(new
NCSingleElementBuilder().withId("additionalElementId").getElement());
- class SomeClassWithIntents {
- @NCIntentRef("remove:waypoint")
- public void x() {
- }
- }
return
new NCModelConfigBuilder().
withDescription("test model").
withElements(elements).
- withIntents(
- new NCIntentsBuilder().
- withClasses(SomeClassWithIntents.class).
- getIntents()
- ).
- withIntentsSamples(
- new NCIntentsSamplesBuilder().
- withClasses(SomeClassWithIntents.class).
- getSamples()
+ withIntentsClasses(
+ asList(SomeClassWithIntents.class)
).
withOnRejection(new BiFunction<NCIntentMatch, NCRejection,
NCResult>() {
@Override
@@ -120,7 +112,7 @@ public class NCSpec {
getElement()
)
).
- withIntents(asMap("req", null)). // TODO: "intent=req
term(date)~{# == 'opennlp:date'}?")).
+ withIntentsObjects(asList(new SomeClassWithIntents())).
getModelConfig()
).getModel();