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/02/15 22:08:36 UTC

[incubator-nlpcraft] branch NLPCRAFT-236 updated: Code review,

This is an automated email from the ASF dual-hosted git repository.

aradzinski pushed a commit to branch NLPCRAFT-236
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git


The following commit(s) were added to refs/heads/NLPCRAFT-236 by this push:
     new 968c016  Code review,
968c016 is described below

commit 968c016b9a3143b85146ba4022a65578cc6cde75
Author: Aaron Radzinski <ar...@apache.org>
AuthorDate: Mon Feb 15 14:08:25 2021 -0800

    Code review,
---
 .../apache/nlpcraft/common/nlp/NCNlpSentence.scala |  6 ++----
 .../examples/misc/geo/keycdn/GeoManager.java       |  2 +-
 .../scala/org/apache/nlpcraft/model/NCElement.java |  2 +-
 .../org/apache/nlpcraft/model/NCModelView.java     | 23 ++++++++++++++++++----
 4 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
index 50a158b..e7aecd3 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/nlp/NCNlpSentence.scala
@@ -59,9 +59,7 @@ object NCNlpSentence extends LazyLogging {
           * should not be excluded, but invalid relation should be deleted for these combinations.
           */
         types.size match {
-            case 0 ⇒
-                //TODO: add some tests? throw new AssertionError(s"Unexpected empty types [notesType=$notesType]")
-                false
+            case 0 ⇒ false
             case 1 ⇒ types.head == notesType
             case _ ⇒
                 // Equal elements should be processed together with function element.
@@ -696,7 +694,7 @@ class NCNlpSentence(
                                     val mainNotes =
                                         savedDelToks.flatten.filter(n ⇒ n.noteType != "nlpcraft:nlp" && n != savedDelNote)
 
-                                    // Deleted note's tokens shopuld contains only nlp data and deleted notes.
+                                    // Deleted note's tokens should contains only nlp data and deleted notes.
                                     for (savedDelTok ← savedDelToks; mainNote ← mainNotes)
                                         savedDelTok.remove(mainNote)
 
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/geo/keycdn/GeoManager.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/geo/keycdn/GeoManager.java
index 23792f4..7f0b7e9 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/geo/keycdn/GeoManager.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/examples/misc/geo/keycdn/GeoManager.java
@@ -90,7 +90,7 @@ public class GeoManager {
             
             HttpURLConnection conn = (HttpURLConnection)(new URL(URL + host).openConnection());
     
-            // This service requires "User-Agent" property for some reasons with its own format (See docs).
+            // This service requires "User-Agent" property with its own format.
             conn.setRequestProperty("User-Agent", "keycdn-tools:https://nlpcraft.apache.org");
     
             try (InputStream in = conn.getInputStream()) {
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
index 3da7f5a..9ff5bf7 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCElement.java
@@ -149,7 +149,7 @@ public interface NCElement extends NCMetadata, Serializable {
      *     ]
      * </pre>
      *
-     * @return Element's metadata or empty collection if none provided. Default implementation return empty collection. TODO:
+     * @return Element's metadata or empty collection if none provided. Default implementation return empty collection.
      */
     default Map<String, Object> getMetadata() {
         return Collections.emptyMap();
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
index 34426ad..2633557 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelView.java
@@ -691,7 +691,7 @@ public interface NCModelView extends NCMetadata {
      * }
      * </pre>
      *
-     * @return Optional user defined model metadata. TODO: cannot be null
+     * @return Optional user defined model metadata. By default, returns an empty map. Never returns {@code null}.
      */
     default Map<String, Object> getMetadata() {
         return DFLT_METADATA;
@@ -830,7 +830,7 @@ public interface NCModelView extends NCMetadata {
      * }
      * </pre>
      *
-     * @return Custom user parsers for model elements or {@code null} if not used (default). TODO: cannot be null!
+     * @return Custom user parsers for model elements or empty list if not used (default). Never returns {@code null}.
      */
     default List<NCCustomParser> getParsers() {
         return Collections.emptyList();
@@ -907,13 +907,28 @@ public interface NCModelView extends NCMetadata {
      * }
      * </pre>
      *
-     * @return Set of built-in tokens, potentially empty, that should be enabled and detected for this model.
+     * @return Set of built-in tokens, potentially empty but never {@code null}, that should be enabled
+     *      and detected for this model.
      */
     default Set<String> getEnabledBuiltInTokens() {
         return DFLT_ENABLED_BUILTIN_TOKENS;
     }
 
-    // TODO:
+    /**
+     * Gets s set of named entities (token) IDs that will be considered as abstract tokens.
+     * An abstract token is only detected when it is either a constituent part of some other non-abstract token
+     * or referenced by built-in tokens. In other words, an abstract token will not be detected in a standalone
+     * unreferenced position. By default (unless returned by this method), all named entities considered to be
+     * non-abstract.
+     * <p>
+     * Declaring tokens as abstract is important to minimize number of parsing variants automatically
+     * generated as permutation of all possible parsing compositions. For example, if it is known that a particular
+     * named entity will only be used as a constituent part of some other token - declaring such named entity as
+     * abstract can significantly reduce the number of parsing variants leading to a better performance,
+     * and often simpler corresponding intent definition and callback logic.
+     *
+     * @return Set of abstract token IDs. Can be empty but never {@code null}.
+     */
     default Set<String> getAbstractTokens() {
         return Collections.emptySet();
     }