You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2020/12/21 11:12:58 UTC

[incubator-nlpcraft] branch NLPCRAFT-203 updated: WIP.

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

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


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

commit 35cc7471c505a649c702db69d127eddf127cde02
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Mon Dec 21 14:12:40 2020 +0300

    WIP.
---
 .../nlpcraft/model/intent/impl/NCIntentSolverEngine.scala | 15 +++++++++++----
 .../apache/nlpcraft/model/NCIntentPrioritiesSpec.scala    |  1 +
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
index db41dd0..d7c6af8 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/intent/impl/NCIntentSolverEngine.scala
@@ -224,10 +224,17 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
                                 case x2 ⇒
                                     require(x2 == 0)
 
-                                    def calcHash(m: MatchHolder): Int =
-                                        m.variant.tokens.map(t ⇒
-                                            s"${t.getId}${t.getGroups}${t.getValue}${t.normText}"
-                                        ).mkString("").hashCode
+                                    def calcHash(m: MatchHolder): Int = {
+                                        val variantPart =
+                                            m.variant.
+                                            tokens.
+                                            map(t ⇒ s"${t.getId}${t.getGroups}${t.getValue}${t.normText}").
+                                            mkString("")
+
+                                        val intentPart = m.intentMatch.intent.toString
+
+                                        (variantPart, intentPart).##
+                                    }
 
                                     // Order doesn't make sense here.
                                     // It is just to provide deterministic result for the matches with the same weight.
diff --git a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/NCIntentPrioritiesSpec.scala b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/NCIntentPrioritiesSpec.scala
index a49079c..f0a2da6 100644
--- a/nlpcraft/src/test/scala/org/apache/nlpcraft/model/NCIntentPrioritiesSpec.scala
+++ b/nlpcraft/src/test/scala/org/apache/nlpcraft/model/NCIntentPrioritiesSpec.scala
@@ -56,6 +56,7 @@ class NCIntentPrioritiesSpec extends NCTestContext {
         checkHigh(
             "Moscow x",
             "London x",
+            "x London",
             "x berlin",
             "x Berlin, Germany"
         )