Searching other subjects, if the result match is too low

This commit is contained in:
mrfry 2020-11-12 11:24:43 +01:00
parent 098620cce2
commit fa2fd6274f
2 changed files with 16 additions and 6 deletions

View file

@ -19,8 +19,7 @@
"nextdir": "nextStatic/qminingPagePublic", "nextdir": "nextStatic/qminingPagePublic",
"name": "qmining", "name": "qmining",
"urls": [ "urls": [
"qmining.frylabs.net", "qmining.frylabs.net"
"localhost"
], ],
"isNextJs": true "isNextJs": true
}, },
@ -31,7 +30,8 @@
], ],
"name": "api", "name": "api",
"urls": [ "urls": [
"api.frylabs.net" "api.frylabs.net",
"localhost"
] ]
}, },
"main": { "main": {

View file

@ -28,8 +28,13 @@ const commonUselessAnswerParts = [
const commonUselessStringParts = [',', '\\.', ':', '!', '\\+', '\\s*\\.'] const commonUselessStringParts = [',', '\\.', ':', '!', '\\+', '\\s*\\.']
const specialChars = ['&', '\\+'] const specialChars = ['&', '\\+']
const lengthDiffMultiplier = 10 /* Percent minus for length difference */ /* Percent minus for length difference */
const minMatchAmmount = 60 /* Minimum ammount to consider that two questions match during answering */ 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 // String Utils
@ -484,7 +489,12 @@ if (!isMainThread) {
}) })
// FIXME: try to remove this? but this is also a good backup plan so idk // 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( logger.DebugLog(
'Reqults length is zero when comparing names, trying all subjects', 'Reqults length is zero when comparing names, trying all subjects',
'qdb search', 'qdb search',