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/09/18 07:10:16 UTC
[incubator-nlpcraft] 01/12: WIP.
This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
commit 461fd78c8fdbe20dc3178b8cbbdfb785d6a98947
Author: Sergey Kamov <se...@apache.org>
AuthorDate: Wed Sep 16 15:35:44 2020 +0300
WIP.
---
.../model/intent/impl/NCIntentSolverEngine.scala | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 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 ac29a95..1e0e6cb 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
@@ -249,11 +249,11 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
tbl += (
Seq(
s"#${m.variantIdx + 1}",
- s"${ansiRedFg}<<best match>>$ansiReset"
+ s"$ansiRedFg<<best match>>$ansiReset"
),
Seq(
im.intent.id,
- s"${ansiRedFg}<<best match>>$ansiReset"
+ s"$ansiRedFg<<best match>>$ansiReset"
),
mkPickTokens(im)
)
@@ -404,6 +404,7 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
// Check dialog flow first.
if (!intent.flow.isEmpty && !matchFlow(intent.flow, hist)) {
logger.info(s"Intent '$intentId' didn't match because of dialog flow $varStr.")
+
None
}
else {
@@ -459,9 +460,17 @@ object NCIntentSolverEngine extends LazyLogging with NCOpenCensusTrace {
None
}
else {
- val exactMatch = !senToks.exists(tok ⇒ !tok.used && !tok.token.isFreeWord)
-
- intentW.setWeight(0, if (exactMatch) 1 else 0)
+ val exactMatch = !(senToks ++ convToks).exists(tok ⇒ !tok.used && !tok.token.isFreeWord)
+
+ val mainWeight =
+ if (exactMatch && convToks.isEmpty)
+ 2
+ else if (exactMatch)
+ 1
+ else
+ 0
+
+ intentW.setWeight(0, mainWeight)
Some(IntentMatch(
tokenGroups = intentGrps.toList,