This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch scala-2.13
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/scala-2.13 by this push:
new add399d WIP.
add399d is described below
commit add399d294a8a0a1ea30a50d6ad6735bf6cfdfe8
Author: Aaron Radzinzski <[email protected]>
AuthorDate: Thu May 20 10:36:19 2021 -0700
WIP.
---
.../src/main/scala/org/apache/nlpcraft/model/NCToken.java | 13 +++++++++++++
.../scala/org/apache/nlpcraft/model/impl/NCTokenPimp.scala | 2 +-
.../model/intent/solver/NCIntentSolverVariant.scala | 6 +++---
3 files changed, 17 insertions(+), 4 deletions(-)
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 22dad76..4916084 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCToken.java
@@ -447,6 +447,19 @@ public interface NCToken extends NCMetadata {
default int getSparsity() { return meta("nlpcraft:nlp:sparsity"); }
/**
+ * A shortcut method to get of individual separate words in this token.
+ * <p>
+ * This method is equivalent to:
+ * <pre class="brush: java">
+ * return meta("nlpcraft:nlp:wordlength");
+ * </pre>
+ * See more information on token metadata <a target=_
href="https://nlpcraft.apache.org/data-model.html#meta">here</a>.
+ *
+ * @return Number of individual separate words in this token.
+ */
+ default int getWordLength() { return meta("nlpcraft:nlp:wordlength"); }
+
+ /**
* A shortcut method to get Penn Treebank POS tag for this token. Note
that additionally to standard Penn
* Treebank POS tags NLPCraft introduced '---' synthetic tag to indicate a
POS tag for multiword tokens.
* <p>
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 5d8a215..fce547c 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
@@ -25,7 +25,7 @@ import scala.jdk.CollectionConverters._
*
*/
object NCTokenPimp {
- implicit def x(tok: NCToken): NCTokenPimp = new NCTokenPimp(tok)
+ implicit def x(tok: NCToken): NCTokenPimp = new NCTokenPimp(tok)
private final val SYS = Set("nlpcraft", "google", "opennlp", "spacy",
"stanford")
}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
index f8b1a21..194864c 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/solver/NCIntentSolverVariant.scala
@@ -19,9 +19,9 @@ package org.apache.nlpcraft.model.intent.solver
import org.apache.nlpcraft.common._
import org.apache.nlpcraft.model.NCToken
+import org.apache.nlpcraft.model.impl.NCTokenPimp._
import scala.jdk.CollectionConverters._
-
import java.util
/**
@@ -44,8 +44,8 @@ case class NCIntentSolverVariant(tokens: util.List[NCToken])
extends Ordered[NCI
for (tok <- tokens.asScala) {
if (!tok.isFreeWord && !tok.isStopWord) {
- wordCnt += tok.wordLength
- totalSparsity += tok.sparsity
+ wordCnt += tok.getWordLength
+ totalSparsity += tok.getSparsity
if (tok.isUserDefined) {
userToks += 1