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/04/16 05:28:12 UTC

[incubator-nlpcraft] branch master updated: WIP.

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

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


The following commit(s) were added to refs/heads/master by this push:
     new c9572d7  WIP.
c9572d7 is described below

commit c9572d7b767ed63ad7e02302f3edb1708a56aa83
Author: Aaron Radzinzski <ar...@datalingvo.com>
AuthorDate: Fri Apr 16 08:28:03 2021 +0300

    WIP.
---
 .../src/main/scala/org/apache/nlpcraft/model/NCToken.java   | 13 +++++++++++++
 .../scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala  |  1 +
 2 files changed, 14 insertions(+)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java
index 38afc21..1e71758 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java
@@ -317,6 +317,19 @@ public interface NCToken extends NCMetadata {
     default boolean isDirect() { return meta("nlpcraft:nlp:direct"); }
 
     /**
+     * A shortcut method on whether or not this token was matched on permutated (not direct) synonym.
+     * <p>
+     * This method is equivalent to:
+     * <pre class="brush: java">
+     *     return !meta("nlpcraft:nlp:direct");
+     * </pre>
+     * See more information on token metadata <a target=_ href="https://nlpcraft.apache.org/data-model.html#meta">here</a>.
+     *
+     * @return Whether or not this token was matched on permutated (not direct) synonym.
+     */
+    default boolean isPermutated() { return !isDirect(); }
+
+    /**
      * A shortcut method on whether this token represents an English word. Note that this only
      * checks that token's text consists of characters of English alphabet, i.e. the text
      * doesn't have to be necessary a known valid English word.
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
index 9db5cbf..3710092 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala
@@ -40,6 +40,7 @@ class NCTokenPimp(impl: NCToken) {
     def isFreeWord: Boolean = impl.meta("nlpcraft:nlp:freeword")
     def isQuoted: Boolean = impl.meta("nlpcraft:nlp:quoted")
     def isDirect: Boolean = impl.meta("nlpcraft:nlp:direct")
+    def isPermutated: Boolean = !isDirect
     def isBracketed: Boolean = impl.meta("nlpcraft:nlp:bracketed")
     def wordIndexes: List[Int] = impl.meta[java.util.List[Int]]("nlpcraft:nlp:wordindexes").asScala.toList
     def origText: String = impl.meta("nlpcraft:nlp:origtext")