mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-23 13:09:00 +00:00
(index) Tune ranking for verbatim matches in the title, rewarding shorter titles
This commit is contained in:
parent
dd15676d33
commit
b21f8538a8
@ -280,6 +280,9 @@ public class IndexResultScoreCalculator {
|
||||
if (positions[i] != null && ctx.regularMask.get(i)) {
|
||||
searchableKeywordsCount ++;
|
||||
|
||||
boolean titleMatch = false;
|
||||
boolean headingMatch = false;
|
||||
|
||||
var iter = positions[i].iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
@ -288,11 +291,11 @@ public class IndexResultScoreCalculator {
|
||||
firstPosition = Math.max(firstPosition, pos);
|
||||
|
||||
if (spans.title.containsPosition(pos)) {
|
||||
unorderedMatchInTitleCount++;
|
||||
titleMatch = true;
|
||||
weightedCounts[i] += 2.5f;
|
||||
}
|
||||
else if (spans.heading.containsPosition(pos)) {
|
||||
unorderedMatchInHeadingCount++;
|
||||
headingMatch = true;
|
||||
weightedCounts[i] += 2.5f;
|
||||
}
|
||||
else if (spans.code.containsPosition(pos))
|
||||
@ -302,10 +305,17 @@ public class IndexResultScoreCalculator {
|
||||
else if (spans.nav.containsPosition(pos))
|
||||
weightedCounts[i] += 0.1f;
|
||||
}
|
||||
|
||||
if (titleMatch) {
|
||||
unorderedMatchInTitleCount++;
|
||||
}
|
||||
if (headingMatch) {
|
||||
unorderedMatchInHeadingCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!verbatimMatchInTitle && unorderedMatchInTitleCount == searchableKeywordsCount) {
|
||||
if (!verbatimMatchInTitle && searchableKeywordsCount > 2 && unorderedMatchInTitleCount == searchableKeywordsCount) {
|
||||
coherenceScore += 2.5f * unorderedMatchInTitleCount;
|
||||
coherenceScore += 2.f * unorderedMatchInTitleCount / titleLength;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user