From fa2fd6274f7f899bda983ff26fb253f9b65f3f3a Mon Sep 17 00:00:00 2001 From: mrfry Date: Thu, 12 Nov 2020 11:24:43 +0100 Subject: [PATCH] Searching other subjects, if the result match is too low --- src/modules.json | 6 +++--- src/utils/classes.js | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/modules.json b/src/modules.json index df25d58..479ca8f 100644 --- a/src/modules.json +++ b/src/modules.json @@ -19,8 +19,7 @@ "nextdir": "nextStatic/qminingPagePublic", "name": "qmining", "urls": [ - "qmining.frylabs.net", - "localhost" + "qmining.frylabs.net" ], "isNextJs": true }, @@ -31,7 +30,8 @@ ], "name": "api", "urls": [ - "api.frylabs.net" + "api.frylabs.net", + "localhost" ] }, "main": { diff --git a/src/utils/classes.js b/src/utils/classes.js index 9d4e4a7..df7236f 100755 --- a/src/utils/classes.js +++ b/src/utils/classes.js @@ -28,8 +28,13 @@ const commonUselessAnswerParts = [ const commonUselessStringParts = [',', '\\.', ':', '!', '\\+', '\\s*\\.'] const specialChars = ['&', '\\+'] -const lengthDiffMultiplier = 10 /* Percent minus for length difference */ -const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */ +/* Percent minus for length difference */ +const lengthDiffMultiplier = 10 +/* Minimum ammount to consider that two questions match during answering */ +const minMatchAmmount = 60 +/* If all of the results are below this match percent (when only one subject is searched due to + * subject name matching) then all subjects are searched for answer */ +const minMatchToNotSearchOtherSubjects = 90 // --------------------------------------------------------------------------------------------------------- // String Utils @@ -484,7 +489,12 @@ if (!isMainThread) { }) // FIXME: try to remove this? but this is also a good backup plan so idk - if (result.length === 0) { + // its sufficent to check only result[0].match, since its sorted, and the first one should have + // the highest match + if ( + result.length === 0 || + result[0].match < minMatchToNotSearchOtherSubjects + ) { logger.DebugLog( 'Reqults length is zero when comparing names, trying all subjects', 'qdb search',