This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-477
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-477 by this push:
new 0fed39d WIP.
0fed39d is described below
commit 0fed39dbdf27ea362a0c7b8f789be18dc0302484
Author: Sergey Kamov <[email protected]>
AuthorDate: Mon Feb 7 15:54:31 2022 +0300
WIP.
---
.../internal/intent/matcher/NCIntentSolverVariant.scala | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverVariant.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverVariant.scala
index 19b67ff..01a0505 100644
---
a/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverVariant.scala
+++
b/nlpcraft/src/main/scala/org/apache/nlpcraft/internal/intent/matcher/NCIntentSolverVariant.scala
@@ -34,20 +34,20 @@ case class NCIntentSolverVariant(entities: Seq[NCEntity])
extends Ordered[NCInte
*/
private def calcSparsity(toks: Seq[NCToken]): Int =
val idxs = toks.map(_.getIndex)
- idxs.zipWithIndex.tail.map { case (v, i) => Math.abs(v - idxs(i - 1))
}.sum - idxs.length + 1
+ idxs.zipWithIndex.tail.map { (v, i) => Math.abs(v - idxs(i - 1)) }.sum
- idxs.length + 1
/**
- * Calculates weight components.
+ * Calculates weight components sequence.
*/
private def calcWeight(): Seq[Int] =
val toks: Seq[Seq[NCToken]] = entities.map(_.getTokens.asScala.toSeq)
val toksCnt = toks.map(_.size).sum
- val avgWordsPerEntity = if toksCnt > 0 then
Math.round((entities.size.toFloat / toksCnt) * 100) else 0
+ val avgToksPerEntity = if toksCnt > 0 then
Math.round((entities.size.toFloat / toksCnt) * 100) else 0
val totalSparsity = -toks.map(calcSparsity).sum // Less is better.
// Order is important.
- Seq(toksCnt, avgWordsPerEntity, totalSparsity)
+ Seq(toksCnt, avgToksPerEntity, totalSparsity)
override def compare(other: NCIntentSolverVariant): Int =
def compareWeight(weight1: Int, weight2: Int): Option[Int] =
@@ -55,4 +55,4 @@ case class NCIntentSolverVariant(entities: Seq[NCEntity])
extends Ordered[NCInte
else if weight2 > weight1 then Option(-1)
else None
- weights.zip(other.weights).flatMap { (w1, w2) => compareWeight(w1,
w2)}.to(LazyList).headOption.getOrElse(0)
\ No newline at end of file
+ weights.zip(other.weights).flatMap { (w1, w2) => compareWeight(w1, w2)
}.to(LazyList).headOption.getOrElse(0)
\ No newline at end of file