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

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


The following commit(s) were added to refs/heads/NLPCRAFT-443 by this push:
     new 8d868f9  WIP.
8d868f9 is described below

commit 8d868f9e08242d7cbdab78ecd9214c1f56090838
Author: Sergey Kamov <[email protected]>
AuthorDate: Sat Sep 25 21:01:54 2021 +0300

    WIP.
---
 .../nlpcraft/probe/mgrs/NCProbeIdlToken.scala      | 48 ++++------------------
 1 file changed, 9 insertions(+), 39 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeIdlToken.scala 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeIdlToken.scala
index 69a2f2f..b2a8310 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeIdlToken.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/NCProbeIdlToken.scala
@@ -22,25 +22,16 @@ import org.apache.nlpcraft.model.{NCToken, _}
 
 /**
   *
-  * @param isToken
-  * @param isWord
   * @param token
   * @param word
-  * @param origText
-  * @param wordIndexes
-  * @param minIndex
-  * @param maxIndex
   */
-case class NCProbeIdlToken(
-    isToken: Boolean,
-    isWord: Boolean,
-    token: NCToken,
-    word: NCNlpSentenceToken,
-    origText: String,
-    wordIndexes: Set[Int],
-    minIndex: Int,
-    maxIndex: Int
-) {
+case class NCProbeIdlToken(token: NCToken, word: NCNlpSentenceToken) {
+    val (origText: String, wordIndexes: Set[Int], minIndex: Int, maxIndex: 
Int, isToken: Boolean, isWord: Boolean) =
+        if (isToken)
+            (token.origText, token.wordIndexes.toSet, token.wordIndexes.head, 
token.wordIndexes.last, true, false)
+        else
+            (word.origText, word.wordIndexes.toSet, word.wordIndexes.head, 
word.wordIndexes.last, false, true)
+
     private lazy val hash = if (isToken) Seq(wordIndexes, 
token.getId).hashCode() else wordIndexes.hashCode()
 
     override def hashCode(): Int = hash
@@ -70,27 +61,6 @@ case class NCProbeIdlToken(
   *
   */
 object NCProbeIdlToken {
-    def apply(t: NCToken): NCProbeIdlToken =
-        NCProbeIdlToken(
-            isToken = true,
-            isWord = false,
-            token = t,
-            word = null,
-            origText = t.origText,
-            wordIndexes = t.wordIndexes.toSet,
-            minIndex = t.wordIndexes.head,
-            maxIndex = t.wordIndexes.last
-        )
-
-    def apply(t: NCNlpSentenceToken): NCProbeIdlToken =
-        NCProbeIdlToken(
-            isToken = false,
-            isWord = true,
-            token = null,
-            word = t,
-            origText = t.origText,
-            wordIndexes = t.wordIndexes.toSet,
-            minIndex = t.wordIndexes.head,
-            maxIndex = t.wordIndexes.last
-        )
+    def apply(t: NCToken): NCProbeIdlToken = NCProbeIdlToken(token = t, word = 
null)
+    def apply(t: NCNlpSentenceToken): NCProbeIdlToken = NCProbeIdlToken(token 
= null, word = t)
 }

Reply via email to