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

@ -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',