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

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


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

commit 3dfff7f4e280cea530e1151a68c093794acbcebf
Author: Sergey Kamov <[email protected]>
AuthorDate: Sun Jun 14 13:22:16 2020 +0300

    WIP.
---
 .../model/tools/suggestions/NCSuggestionsGenerator.scala      | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/suggestions/NCSuggestionsGenerator.scala
 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/suggestions/NCSuggestionsGenerator.scala
index 87c779e..5e03016 100644
--- 
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/suggestions/NCSuggestionsGenerator.scala
+++ 
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/tools/suggestions/NCSuggestionsGenerator.scala
@@ -232,13 +232,10 @@ object NCSuggestionsGeneratorImpl {
 
         val allSynsStems = elemSyns.flatMap(_._2).flatten.map(_.stem).toSet
 
-        val filteredSuggs =
-            allSuggs.asScala.map {
-                case (elemId, elemSuggs) ⇒ elemId → 
elemSuggs.asScala.filter(_.score >= data.minScore)
-            }.filter(_._2.nonEmpty)
+        val nonEmptySuggs = allSuggs.asScala.map(p ⇒ p._1 → 
p._2.asScala).filter(_._2.nonEmpty)
 
-        val avgScores = filteredSuggs.map { case (elemId, suggs) ⇒ elemId → 
(suggs.map(_.score).sum / suggs.size) }
-        val counts = filteredSuggs.map { case (elemId, suggs) ⇒ elemId → 
suggs.size }
+        val avgScores = nonEmptySuggs.map { case (elemId, suggs) ⇒ elemId → 
(suggs.map(_.score).sum / suggs.size) }
+        val counts = nonEmptySuggs.map { case (elemId, suggs) ⇒ elemId → 
suggs.size }
 
         val tbl = NCAsciiTable()
 
@@ -250,7 +247,7 @@ object NCSuggestionsGeneratorImpl {
             "Summary Score"
         )
 
-        filteredSuggs.
+        nonEmptySuggs.
             foreach { case (elemId, elemSuggs) ⇒
                 val seq: Seq[(Suggestion, Int)] = elemSuggs.
                     map(sugg ⇒ (sugg, toStem(sugg.word))).

Reply via email to