This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-472
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-472 by this push:
new 9a867f8 CR
9a867f8 is described below
commit 9a867f8d83833a998198828df628493cbd327b57
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Jan 12 11:22:12 2022 -0800
CR
---
.../org/apache/nlpcraft/NCEntityValidator.java | 3 +-
.../scala/org/apache/nlpcraft/NCLifecycle.java | 2 +-
.../scala/org/apache/nlpcraft/NCModelAdapter.java | 5 +-
.../scala/org/apache/nlpcraft/NCModelClient.java | 3 +-
.../scala/org/apache/nlpcraft/NCModelConfig.java | 33 ++---
.../apache/nlpcraft/NCModelPipelineBuilder.java | 150 +++++++++------------
.../main/scala/org/apache/nlpcraft/NCResult.java | 4 +-
.../scala/org/apache/nlpcraft/NCResultType.java | 2 +-
.../scala/org/apache/nlpcraft/NCTokenParser.java | 1 -
.../org/apache/nlpcraft/NCTokenValidator.java | 3 +-
.../main/scala/org/apache/nlpcraft/NCVariant.java | 2 +-
.../org/apache/nlpcraft/NCVariantValidator.java | 5 +-
.../internal/{ => client}/NCModelClientImpl.scala | 14 +-
13 files changed, 95 insertions(+), 132 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityValidator.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityValidator.java
index b671761..46c42c4 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityValidator.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCEntityValidator.java
@@ -20,11 +20,10 @@ package org.apache.nlpcraft;
import java.util.List;
/**
- * TODO:
+ *
*/
public interface NCEntityValidator extends NCLifecycle {
/**
- * TODO: Checks parsed entities and throws exceptions, if necessary.
*
* @param req
* @param cfg
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
index d45a1a2..3d9a97b 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCLifecycle.java
@@ -18,7 +18,7 @@
package org.apache.nlpcraft;
/**
- * TODO:
+ *
*/
public interface NCLifecycle {
/**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelAdapter.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelAdapter.java
index 4fdfa4f..45b2e3c 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelAdapter.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelAdapter.java
@@ -32,9 +32,8 @@ public class NCModelAdapter implements NCModel {
* @param pipeline
*/
public NCModelAdapter(NCModelConfig cfg, NCModelPipeline pipeline) {
- // TODO: error texts.
- Objects.requireNonNull(cfg, "Config cannot be null.");
- Objects.requireNonNull(pipeline, "Pipeline cannot be null.");
+ Objects.requireNonNull(cfg, "Model config cannot be null.");
+ Objects.requireNonNull(pipeline, "Model pipeline cannot be null.");
this.cfg = cfg;
this.pipeline = pipeline;
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
index dbfa8f7..1d5dbf3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelClient.java
@@ -17,7 +17,7 @@
package org.apache.nlpcraft;
-import org.apache.nlpcraft.internal.NCModelClientImpl;
+import org.apache.nlpcraft.internal.client.NCModelClientImpl;
import java.util.Map;
import java.util.concurrent.*;
@@ -26,7 +26,6 @@ import java.util.concurrent.*;
*
*/
public class NCModelClient {
- // TODO: move NCModelClientImpl under rigth package.
private final NCModelClientImpl impl;
/**
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
index 304862f..e29411f 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelConfig.java
@@ -23,37 +23,33 @@ import java.util.*;
*
*/
public class NCModelConfig extends NCPropertyMapAdapter {
- private final String id, name, version;
- private String desc, origin;
+ private final String id, name, ver, desc, origin;
/**
- * TODO:
* @param id
* @param name
- * @param version
+ * @param ver
*/
- public NCModelConfig(String id, String name, String version) {
- // TODO: error texts.
- Objects.requireNonNull(id, "Id cannot be null.");
- Objects.requireNonNull(name, "Name cannot be null.");
- Objects.requireNonNull(version, "Version cannot be null.");
-
- this.id = id;
- this.name = name;
- this.version = version;
+ public NCModelConfig(String id, String name, String ver) {
+ this(id, name, ver, null, null);
}
/**
- * TODO:
+ *
* @param id
* @param name
- * @param version
+ * @param ver
* @param desc
* @param origin
*/
- public NCModelConfig(String id, String name, String version, String desc,
String origin) {
- this(id, name, version);
+ public NCModelConfig(String id, String name, String ver, String desc,
String origin) {
+ Objects.requireNonNull(id, "Model ID cannot be null.");
+ Objects.requireNonNull(name, "Model name cannot be null.");
+ Objects.requireNonNull(ver, "Model version cannot be null.");
+ this.id = id;
+ this.name = name;
+ this.ver = ver;
this.desc = desc;
this.origin = origin != null ? origin : getClass().getCanonicalName();
}
@@ -82,7 +78,7 @@ public class NCModelConfig extends NCPropertyMapAdapter {
* @return A version compatible with (<a
href="http://www.semver.org">www.semver.org</a>) specification.
*/
public String getVersion() {
- return version;
+ return ver;
}
/**
@@ -96,7 +92,6 @@ public class NCModelConfig extends NCPropertyMapAdapter {
}
/**
- * TODO: text (Default implementation ?)
* Gets the origin of this model like name of the class, file path or URL.
* Default implementation return current class name.
*
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
index d1db016..c363741 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModelPipelineBuilder.java
@@ -23,26 +23,24 @@ import java.util.List;
import java.util.Objects;
/**
- * TODO:
+ *
*/
public class NCModelPipelineBuilder {
private final NCTokenParser tokParser;
private final List<NCTokenEnricher> tokEnrichers = new ArrayList<>();
private final List<NCEntityEnricher> entEnrichers = new ArrayList<>();
private final List<NCEntityParser> entParsers = new ArrayList<>();
- private final List<NCTokenValidator> tokenValidators = new ArrayList<>();
- private final List<NCEntityValidator> entityValidators = new ArrayList<>();
- private final List<NCVariantValidator> variantValidators = new
ArrayList<>();
+ private final List<NCTokenValidator> tokVals = new ArrayList<>();
+ private final List<NCEntityValidator> entVals = new ArrayList<>();
+ private final List<NCVariantValidator> varVals = new ArrayList<>();
/**
- * TODO:
- *
+ *
* @param id
* @param name
* @param version
*/
public NCModelPipelineBuilder(NCTokenParser tokParser,
List<NCEntityParser> entParsers) {
- // TODO: error texts.
Objects.requireNonNull(tokParser, "Token parser cannot be null.");
Objects.requireNonNull(entParsers, "Entity parsers cannot be null.");
if (entParsers.isEmpty())
@@ -64,12 +62,11 @@ public class NCModelPipelineBuilder {
/**
* @param tokEnrichers
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withTokenEnrichers(List<NCTokenEnricher>
tokEnrichers) {
- // TODO: error texts.
- Objects.requireNonNull(tokEnrichers, "Enrichers cannot be null.");
- tokEnrichers.forEach(p -> Objects.requireNonNull(p, "Enrichers cannot
be null."));
+ Objects.requireNonNull(tokEnrichers, "List of token enrichers cannot
be null.");
+ tokEnrichers.forEach(p -> Objects.requireNonNull(p, "Token enricher
cannot be null."));
this.tokEnrichers.addAll(tokEnrichers);
@@ -78,11 +75,10 @@ public class NCModelPipelineBuilder {
/**
* @param tokEnricher
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withTokenEnricher(NCTokenEnricher
tokEnricher) {
- // TODO: error texts.
- Objects.requireNonNull(tokEnricher, "Enricher cannot be null.");
+ Objects.requireNonNull(tokEnricher, "Token enricher cannot be null.");
this.tokEnrichers.add(tokEnricher);
@@ -91,12 +87,11 @@ public class NCModelPipelineBuilder {
/**
* @param entEnrichers
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withEntityEnrichers(List<NCEntityEnricher>
entEnrichers) {
- // TODO: error texts.
- Objects.requireNonNull(entEnrichers, "Enrichers cannot be null.");
- entEnrichers.forEach(p -> Objects.requireNonNull(p, "Enrichers cannot
be null."));
+ Objects.requireNonNull(entEnrichers, "List of entity enrichers cannot
be null.");
+ entEnrichers.forEach(p -> Objects.requireNonNull(p, "Entity enrichers
cannot be null."));
this.entEnrichers.addAll(entEnrichers);
@@ -105,11 +100,10 @@ public class NCModelPipelineBuilder {
/**
* @param entEnricher
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withEntityEnricher(NCEntityEnricher
entEnricher) {
- // TODO: error texts.
- Objects.requireNonNull(entEnricher, "Enricher cannot be null.");
+ Objects.requireNonNull(entEnricher, "Entity enricher cannot be null.");
this.entEnrichers.add(entEnricher);
@@ -118,12 +112,11 @@ public class NCModelPipelineBuilder {
/**
* @param entParsers
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withEntityParsers(List<NCEntityParser>
entParsers) {
- // TODO: error texts.
- Objects.requireNonNull(entParsers, "Parsers cannot be null.");
- entParsers.forEach(p -> Objects.requireNonNull(p, "Parsers cannot be
null."));
+ Objects.requireNonNull(entParsers, "List of entity parsers cannot be
null.");
+ entParsers.forEach(p -> Objects.requireNonNull(p, "Entity parser
cannot be null."));
this.entParsers.addAll(entParsers);
@@ -132,11 +125,10 @@ public class NCModelPipelineBuilder {
/**
* @param entParser
- * @return
+ * @return This instance for call chaining.
*/
public NCModelPipelineBuilder withEntityParser(NCEntityParser entParser) {
- // TODO: error texts.
- Objects.requireNonNull(entParser, "Parser cannot be null.");
+ Objects.requireNonNull(entParser, "Entity parser cannot be null.");
this.entParsers.add(entParser);
@@ -144,79 +136,76 @@ public class NCModelPipelineBuilder {
}
/**
- * @param tokenValidators
- * @return
+ * @param tokVals
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder withTokenValidators(List<NCTokenValidator>
tokenValidators) {
- // TODO: error texts.
- Objects.requireNonNull(tokenValidators, "Validators cannot be null.");
- tokenValidators.forEach(p -> Objects.requireNonNull(p, "Validators
cannot be null."));
+ public NCModelPipelineBuilder withTokenValidators(List<NCTokenValidator>
tokVals) {
+ Objects.requireNonNull(tokVals, "List of token validators cannot be
null.");
+ tokVals.forEach(p -> Objects.requireNonNull(p, "Token validator cannot
be null."));
- this.tokenValidators.addAll(tokenValidators);
+ this.tokVals.addAll(tokVals);
return this;
}
/**
- * @param tokenValidator
- * @return
+ * @param tokVal
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder withTokenValidator(NCTokenValidator
tokenValidator) {
- // TODO: error texts.
- Objects.requireNonNull(tokenValidator, "Validator cannot be null.");
+ public NCModelPipelineBuilder withTokenValidator(NCTokenValidator tokVal) {
+ Objects.requireNonNull(tokVal, "Token validator cannot be null.");
- this.tokenValidators.add(tokenValidator);
+ this.tokVals.add(tokVal);
return this;
}
/**
- * @param entityValidators
- * @return
+ * @param entVals
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder withEntityValidators(List<NCEntityValidator>
entityValidators) {
- // TODO: error texts.
- Objects.requireNonNull(entityValidators, "Validators cannot be null.");
- entityValidators.forEach(p -> Objects.requireNonNull(p, "Validators
cannot be null."));
+ public NCModelPipelineBuilder withEntityValidators(List<NCEntityValidator>
entVals) {
+ Objects.requireNonNull(entVals, "List of entity validators cannot be
null.");
+ entVals.forEach(p -> Objects.requireNonNull(p, "Entity validators
cannot be null."));
- this.entityValidators.addAll(entityValidators);
+ this.entVals.addAll(entVals);
return this;
}
/**
- * @param entityValidator
- * @return
+ * @param entVal
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder withEntityValidator(NCEntityValidator
entityValidator) {
- Objects.requireNonNull(entityValidator, "Validators cannot be null.");
+ public NCModelPipelineBuilder withEntityValidator(NCEntityValidator
entVal) {
+ Objects.requireNonNull(entVal, "Entity validator cannot be null.");
- this.entityValidators.add(entityValidator);
+ this.entVals.add(entVal);
return this;
}
/**
- * @param variantValidators
- * @return
+ * @param varVals
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder
withVariantValidators(List<NCVariantValidator> variantValidators) {
- Objects.requireNonNull(variantValidators, "Validators cannot be
null.");
- variantValidators.forEach(p -> Objects.requireNonNull(p, "Validators
cannot be null."));
+ public NCModelPipelineBuilder
withVariantValidators(List<NCVariantValidator> varVals) {
+ Objects.requireNonNull(varVals, "List of variant validators cannot be
null.");
+ varVals.forEach(p -> Objects.requireNonNull(p, "Variant validators
cannot be null."));
- this.variantValidators.addAll(variantValidators);
+ this.varVals.addAll(varVals);
return this;
}
/**
- * @param variantValidator
- * @return
+ * @param varVal
+ * @return This instance for call chaining.
*/
- public NCModelPipelineBuilder withVariantValidator(NCVariantValidator
variantValidator) {
- Objects.requireNonNull(variantValidator, "Validator cannot be null.");
+ public NCModelPipelineBuilder withVariantValidator(NCVariantValidator
varVal) {
+ Objects.requireNonNull(varVal, "Variant validator cannot be null.");
- this.variantValidators.add(variantValidator);
+ this.varVals.add(varVal);
return this;
}
@@ -226,39 +215,26 @@ public class NCModelPipelineBuilder {
*/
public NCModelPipeline build() {
return new NCModelPipeline() {
- @Override
- public NCTokenParser getTokenParser() {
+ @Override public NCTokenParser getTokenParser() {
return tokParser;
}
-
- @Override
- public List<NCTokenEnricher> getTokenEnrichers() {
+ @Override public List<NCTokenEnricher> getTokenEnrichers() {
return tokEnrichers;
}
-
- @Override
- public List<NCEntityEnricher> getEntityEnrichers() {
+ @Override public List<NCEntityEnricher> getEntityEnrichers() {
return entEnrichers;
}
-
- @Override
- public List<NCEntityParser> getEntityParsers() {
+ @Override public List<NCEntityParser> getEntityParsers() {
return entParsers;
}
-
- @Override
- public List<NCTokenValidator> getTokenValidators() {
- return tokenValidators;
+ @Override public List<NCTokenValidator> getTokenValidators() {
+ return tokVals;
}
-
- @Override
- public List<NCEntityValidator> getEntityValidators() {
- return entityValidators;
+ @Override public List<NCEntityValidator> getEntityValidators() {
+ return entVals;
}
-
- @Override
- public List<NCVariantValidator> getVariantValidators() {
- return variantValidators;
+ @Override public List<NCVariantValidator> getVariantValidators() {
+ return varVals;
}
};
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.java
index 5461538..5c5dfc3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResult.java
@@ -23,10 +23,10 @@ import java.io.Serializable;
*
*/
public class NCResult implements Serializable {
- /** Data Model result text. */
+ /** Rresult text. */
private Object body;
- /** Data Model result type. */
+ /** Result type. */
private NCResultType type;
/** ID of the intent. */
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.java
index 12edb50..4003441 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCResultType.java
@@ -32,7 +32,7 @@ public enum NCResultType {
ASK_CURATE,
/**
- * Ask user back, i.e. engage in dialog.
+ * Ask user back engaging in dialog.
*/
ASK_DIALOG
}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
index 66200a6..82c5a6e 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenParser.java
@@ -25,7 +25,6 @@ import java.util.List;
public interface NCTokenParser {
/**
*
- * @param cfg
* @param text
* @return
*/
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenValidator.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenValidator.java
index 7a336d8..64616a3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenValidator.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCTokenValidator.java
@@ -20,11 +20,10 @@ package org.apache.nlpcraft;
import java.util.List;
/**
- * TODO:
+ *
*/
public interface NCTokenValidator extends NCLifecycle {
/**
- * TODO: Checks parsed tokens and throws exceptions, if necessary.
*
* @param req
* @param cfg
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariant.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariant.java
index 0f841ac..55ff443 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariant.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariant.java
@@ -20,7 +20,7 @@ package org.apache.nlpcraft;
import java.util.List;
/**
- * TODO:
+ *
*/
public interface NCVariant {
/**
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariantValidator.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariantValidator.java
index 8f28ff5..98aeea5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariantValidator.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/NCVariantValidator.java
@@ -20,12 +20,11 @@ package org.apache.nlpcraft;
import java.util.List;
/**
- * TODO:
+ *
*/
public interface NCVariantValidator extends NCLifecycle {
/**
- * TODO: Filters all found variants.
- *
+ *
* @param req
* @param cfg
* @param toks
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/NCModelClientImpl.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/client/NCModelClientImpl.scala
similarity index 95%
rename from
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/NCModelClientImpl.scala
rename to
nlpcraft/src/main/scala/org/apache/nlpcraft/internal/client/NCModelClientImpl.scala
index e72586a..800ed8d 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/NCModelClientImpl.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/client/NCModelClientImpl.scala
@@ -15,22 +15,20 @@
* limitations under the License.
*/
-package org.apache.nlpcraft.internal
+package org.apache.nlpcraft.internal.client
-import org.apache.nlpcraft.{NCModelPipeline, *}
-import org.apache.nlpcraft.internal.util.NCUtils
import com.typesafe.scalalogging.LazyLogging
+import org.apache.nlpcraft.internal.NCPipelineProcessor
+import org.apache.nlpcraft.internal.util.NCUtils
+import org.apache.nlpcraft.*
+import java.util.{List as JList, Map as JMap}
import java.util.concurrent.*
-import java.util.List as JList
-import java.util.Map as JMap
import java.util.concurrent.atomic.AtomicReference
-import scala.concurrent.ExecutionContext
import scala.collection.mutable
+import scala.concurrent.ExecutionContext
import scala.jdk.CollectionConverters.*
-// TODO: move it to right package.
-
/**
*
* @param mdl