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 6a3a788 WIP.
6a3a788 is described below
commit 6a3a788cefdfa81928784edd4739d8c76dfb2d27
Author: Sergey Kamov <[email protected]>
AuthorDate: Thu Oct 7 18:51:58 2021 +0300
WIP.
---
.../org/apache/nlpcraft/model/NCIntentSkip.java | 5 +
.../apache/nlpcraft/model/NCMacroProcessor.java | 101 ---------------------
.../org/apache/nlpcraft/model/NCModelConfig.java | 2 +-
.../scala/org/apache/nlpcraft/model/NCResult.java | 1 +
.../model/{ => annotations}/NCAddElement.java | 2 +-
.../nlpcraft/model/{ => annotations}/NCIntent.java | 10 +-
.../model/{ => annotations}/NCIntentSample.java | 10 +-
.../model/{ => annotations}/NCIntentTerm.java | 12 ++-
.../{ => annotations/delete}/NCIntentRef.java | 9 +-
.../delete}/NCIntentSampleRef.java | 9 +-
.../delete}/NCModelAddClasses.java | 7 +-
.../delete}/NCModelAddPackage.java | 7 +-
.../nlpcraft/model/impl/NCElementsProvider.java | 10 ++
.../nlpcraft/model/impl/NCIntentsProvider.java | 19 ++++
.../java/org/apache/nlpcraft/model/NCSpec.java | 3 +-
15 files changed, 95 insertions(+), 112 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
index a04ccd1..8e466cf 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
@@ -18,6 +18,11 @@
package org.apache.nlpcraft.model;
import org.apache.nlpcraft.common.*;
+import org.apache.nlpcraft.model.annotations.NCIntent;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
+import org.apache.nlpcraft.model.annotations.NCIntentTerm;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentRef;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentSampleRef;
/**
* Control flow exception to skip current intent. This exception can be thrown
by the intent
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCMacroProcessor.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCMacroProcessor.java
deleted file mode 100644
index e053152..0000000
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCMacroProcessor.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.nlpcraft.model;
-
-import org.apache.nlpcraft.common.NCException;
-import org.apache.nlpcraft.common.makro.NCMacroJavaParserTrait;
-
-import java.util.Set;
-
-/**
- * Standalone synonym macro DSL processor.
- * <p>
- * This processor provides the same macro support as the built-in macro
support in data models.
- * It is a general purpose macro-processor and it can be used standalone when
testing synonyms,
- * developing NERs, visualizing synonyms in toolchains, etc.
- * <p>
- * Read full documentation on synonym macro DSL in <a target=_
href="https://nlpcraft.apache.org/data-model.html">Data Model</a> section and
review
- * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
- */
-public class NCMacroProcessor {
- private final NCMacroJavaParserTrait impl = mkImpl();
-
- // Need to do that in order to avoid Javadoc failures due to mixed
Scala/Java project.
- private static NCMacroJavaParserTrait mkImpl() {
- try {
- return
(NCMacroJavaParserTrait)Class.forName("org.apache.nlpcraft.common.makro.NCMacroJavaParser")
- .getDeclaredConstructor().newInstance();
- }
- catch (Exception e) {
- throw new NCException("Error initializing object of type:
org.apache.nlpcraft.common.makro.NCMacroJavaParser", e);
- }
- }
-
- /**
- * Expands given macro DSL string.
- * <p>
- * Read full documentation on synonym macro DSL in <a target=_
href="https://nlpcraft.apache.org/data-model.html">Data Model</a> section and
review
- * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
- *
- * @param s Macro DSL string to expand.
- * @return Set of macro expansions for a given macro DSL string.
- */
- public Set<String> expand(String s) {
- return impl.expand(s);
- }
-
- /**
- * Adds or overrides given macro.
- *
- * @param name Macro name (typically an upper case string).
- * It must start with '<' and end with '>' symbol.
- * @param macro Value of the macro (any arbitrary string).
- * @return {@code true} if an existing macro was overridden, {@code false}
otherwise.
- */
- public boolean addMacro(String name, String macro) {
- boolean f = impl.hasMacro(name);
-
- impl.addMacro(name, macro);
-
- return f;
- }
-
- /**
- * Removes macro.
- *
- * @param name Name of the macro to remove.
- * @return {@code true} if given macro was indeed found and removed,
{@code false} otherwise.
- */
- public boolean removeMacro(String name) {
- boolean f = impl.hasMacro(name);
-
- impl.removeMacro(name);
-
- return f;
- }
-
- /**
- * Tests whether this processor has given macro.
- *
- * @param name Name of the macro to test.
- * @return {@code true} if macro was found, {@code false} otherwise.
- */
- public boolean hasMacro(String name) {
- return impl.hasMacro(name);
- }
-}
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 5bdae6c..4e8efa1 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelConfig.java
@@ -23,7 +23,7 @@ import java.time.Duration;
import java.util.*;
public interface NCModelConfig extends NCMetadata {
- // TODO: move all defaults into builder?
+ // TODO: move all defaults into NCModelConfigBuilder?
long CONV_TIMEOUT_MIN = 0L;
long CONV_TIMEOUT_MAX = Long.MAX_VALUE;
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
index 5ff6681..1613589 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCResult.java
@@ -59,6 +59,7 @@ import java.util.Collection;
* accept {@code text} result type and ignore everything else.
*/
public class NCResult extends NCMetadataAdapter implements Serializable,
NCMetadata {
+ // TODO: why is it not interface?
/** Data Model result text. */
private String body;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCAddElement.java
similarity index 97%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCAddElement.java
index b6aadfd..1cc7202 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCAddElement.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCAddElement.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntent.java
similarity index 88%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntent.java
index c8963e1..135d95a 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntent.java
@@ -15,7 +15,15 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations;
+
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentRef;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentSampleRef;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddClasses;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddPackage;
import java.lang.annotation.*;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentSample.java
similarity index 88%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentSample.java
index b18f44a..1720949 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentSample.java
@@ -15,7 +15,15 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations;
+
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentRef;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentSampleRef;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddClasses;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddPackage;
import java.lang.annotation.*;
import static java.lang.annotation.ElementType.METHOD;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentTerm.java
similarity index 84%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentTerm.java
index d8302ac..247f91c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/NCIntentTerm.java
@@ -15,7 +15,17 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations;
+
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.model.annotations.NCIntent;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentRef;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentSampleRef;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddClasses;
+import org.apache.nlpcraft.model.annotations.delete.NCModelAddPackage;
import java.lang.annotation.*;
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentRef.java
similarity index 88%
rename from nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentRef.java
index 3348ffe..522cef6 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentRef.java
@@ -15,7 +15,14 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations.delete;
+
+import org.apache.nlpcraft.model.annotations.NCIntent;
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.annotations.NCIntentTerm;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
import java.lang.annotation.*;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentSampleRef.java
similarity index 91%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentSampleRef.java
index 84dad3f..e13dd48 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCIntentSampleRef.java
@@ -15,7 +15,14 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations.delete;
+
+import org.apache.nlpcraft.model.annotations.NCIntent;
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.annotations.NCIntentTerm;
+import org.apache.nlpcraft.model.NCModel;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
import java.lang.annotation.Documented;
import java.lang.annotation.Repeatable;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddClasses.java
similarity index 89%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddClasses.java
index 8dd5c38..20d853f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddClasses.java
@@ -15,7 +15,12 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations.delete;
+
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.annotations.NCIntentTerm;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddPackage.java
similarity index 89%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddPackage.java
index 584ac62..97ca59d 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/annotations/delete/NCModelAddPackage.java
@@ -15,7 +15,12 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.model;
+package org.apache.nlpcraft.model.annotations.delete;
+
+import org.apache.nlpcraft.model.NCIntentMatch;
+import org.apache.nlpcraft.model.NCIntentSkip;
+import org.apache.nlpcraft.model.annotations.NCIntentTerm;
+import org.apache.nlpcraft.model.annotations.NCIntentSample;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCElementsProvider.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCElementsProvider.java
index 0684672..031ac9c 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCElementsProvider.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCElementsProvider.java
@@ -3,6 +3,7 @@ package org.apache.nlpcraft.model.impl;
import org.apache.nlpcraft.model.NCElement;
import org.apache.nlpcraft.model.NCValueLoader;
+import java.net.URL;
import java.util.List;
import java.util.Map;
import java.io.File;
@@ -10,6 +11,7 @@ import java.io.File;
public class NCElementsProvider {
private Map<String, NCValueLoader> loaders;
private List<File> files;
+ private List<URL> urls;
private List<Class<?>> classes;
public Map<String, NCValueLoader> getLoaders() {
@@ -36,6 +38,14 @@ public class NCElementsProvider {
this.classes = classes;
}
+ public List<URL> getUrls() {
+ return urls;
+ }
+
+ public void setUrls(List<URL> urls) {
+ this.urls = urls;
+ }
+
public List<NCElement> getElements() {
// TODO: implement.
return null;
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCIntentsProvider.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCIntentsProvider.java
index bbc89d6..f08d648 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCIntentsProvider.java
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCIntentsProvider.java
@@ -1,13 +1,16 @@
package org.apache.nlpcraft.model.impl;
import java.io.File;
+import java.net.URL;
import java.util.List;
import java.util.Map;
public class NCIntentsProvider {
private List<File> intentsFiles;
+ private List<URL> intentsUrls;
// Intent ID - samples
private Map<String, File> samplesFiles;
+ private Map<String, URL> samplesUrls;
private List<Class<?>> classes;
public List<File> getIntentsFiles() {
@@ -34,6 +37,22 @@ public class NCIntentsProvider {
this.classes = classes;
}
+ public List<URL> getIntentsUrls() {
+ return intentsUrls;
+ }
+
+ public void setIntentsUrls(List<URL> intentsUrls) {
+ this.intentsUrls = intentsUrls;
+ }
+
+ public Map<String, URL> getSamplesUrls() {
+ return samplesUrls;
+ }
+
+ public void setSamplesUrls(Map<String, URL> samplesUrls) {
+ this.samplesUrls = samplesUrls;
+ }
+
public List<String> getIntentsDls() {
// TODO: implement.
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 4d9af99..093890c 100644
--- a/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
+++ b/nlpcraft/src/test/java/org/apache/nlpcraft/model/NCSpec.java
@@ -1,7 +1,6 @@
package org.apache.nlpcraft.model;
-import org.apache.nlpcraft.model.NCModelConfig;
-import org.apache.nlpcraft.model.NCValueLoader;
+import org.apache.nlpcraft.model.annotations.delete.NCIntentRef;
import org.apache.nlpcraft.model.builders.NCElementBuilder;
import org.apache.nlpcraft.model.builders.NCModelBehaviourBuilder;
import org.apache.nlpcraft.model.builders.NCModelConfigBuilder;