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 2020/09/06 03:17:37 UTC
[incubator-nlpcraft] branch NLPCRAFT-41 updated: Update
NCModelFileAdapter.java
This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-41
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-41 by this push:
new a978ac7 Update NCModelFileAdapter.java
a978ac7 is described below
commit a978ac74c3473d5a6cb9fb2f76d2ca40cb7bf9c5
Author: Aaron Radzinski <ar...@datalingvo.com>
AuthorDate: Sat Sep 5 20:17:23 2020 -0700
Update NCModelFileAdapter.java
---
.../apache/nlpcraft/model/NCModelFileAdapter.java | 30 ++++++++++++----------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelFileAdapter.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelFileAdapter.java
index c1efb27..05b43a5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelFileAdapter.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelFileAdapter.java
@@ -34,7 +34,19 @@ import java.util.stream.*;
* JSON/YAML file and then update it in the code. For example, a model can load its configuration
* from JSON file and then add intents or synonyms loaded from a database to a certain model element.
* To support this usage all getters return internal mutable sets or maps, i.e. you can modify them in your sub-class
- * constructors and those modifications will alter the model's configuration.
+ * constructors and those modifications will alter the model's configuration. The following getters return
+ * mutable collections that can be modified by the caller:
+ * <ul>
+ * <li>{@link #getSuspiciousWords()}</li>
+ * <li>{@link #getAdditionalStopWords()}</li>
+ * <li>{@link #getIntents()}</li>
+ * <li>{@link #getElements()}</li>
+ * <li>{@link #getEnabledBuiltInTokens()}</li>
+ * <li>{@link #getExcludedStopWords()}</li>
+ * <li>{@link #getParsers()}</li>
+ * <li>{@link #getMacros()}</li>
+ * <li>{@link #getMetadata()}</li>
+ * </ul>
* <p>
* Read full documentation 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/src/main/scala/org/apache/nlpcraft/examples/">examples</a>.
@@ -92,7 +104,7 @@ abstract public class NCModelFileAdapter extends NCModelAdapter {
this.proxy = proxy;
this.suspWords = convert(proxy.getSuspiciousWords());
- this.enabledToks = convert(proxy.getEnabledBuiltInTokens(), DFLT_ENABLED_BUILTIN_TOKENS);
+ this.enabledToks = convert(proxy.getEnabledBuiltInTokens());
this.addStopwords = convert(proxy.getAdditionalStopwords());
this.exclStopwords = convert(proxy.getExcludedStopwords());
this.elems = convertElements(proxy.getElements());
@@ -179,15 +191,6 @@ abstract public class NCModelFileAdapter extends NCModelAdapter {
throw new NCException("Unsupported model configuration file type (.yaml, .yml, .js or .json only): " + path);
}
-
- /**
- *
- * @param arr
- * @return
- */
- private static Set<String> convert(String[] arr) {
- return arr == null ? new HashSet<>() : new HashSet<>(Arrays.asList(arr));
- }
/**
*
@@ -203,11 +206,10 @@ abstract public class NCModelFileAdapter extends NCModelAdapter {
/**
*
* @param arr
- * @param dflt
* @return
*/
- private static Set<String> convert(String[] arr, Set<String> dflt) {
- return arr == null ? new HashSet<>(dflt) : new HashSet<>(Arrays.asList(arr));
+ private static Set<String> convert(String[] arr) {
+ return arr == null ? new HashSet<>(NCModelView.DFLT_ENABLED_BUILTIN_TOKENS) : new HashSet<>(Arrays.asList(arr));
}
/**