Tweaking search result valuation

This commit is contained in:
Viktor Lofgren 2023-01-11 19:33:05 +01:00
parent 085d985e61
commit fb2797a8ef
2 changed files with 27 additions and 4 deletions

View File

@ -149,10 +149,10 @@ public class IndexResultValuator {
positions = EdgePageWordMetadata.decodePositions(meta);
maskAdjacent &= (positions | (positions << 1) | (positions >>> 1));
maskDirectRaw &= positions;
if (positions == 0 && !EdgePageWordMetadata.hasAnyFlags(meta, flagBitMask)) {
if (positions != 0 && !EdgePageWordMetadata.hasAnyFlags(meta, flagBitMask)) {
maskAdjacent &= (positions | (positions << 1) | (positions >>> 1));
maskDirectGenerous &= positions;
}

View File

@ -145,18 +145,41 @@ public class SearchResultValuator {
totalFactor *= getAllTermsFactor(keyword, totalWeight, titleLength);
}
totalFactor = calculateTermCoherencePenalty(set, totalFactor);
if (set.keywords.length > 1) {
totalFactor = calculateTermCoherencePenalty(set, totalFactor);
}
else {
totalFactor = calculateSingleTermBonus(set, totalFactor);
}
return totalFactor;
}
private double calculateSingleTermBonus(SearchResultsKeywordSet set, double totalFactor) {
var theKeyword = set.iterator().next();
if (theKeyword.wordMetadata.hasFlag(EdgePageWordFlags.Title)) {
return totalFactor * 0.5;
}
else if (theKeyword.wordMetadata.hasFlag(EdgePageWordFlags.Subjects)) {
return totalFactor * 0.6;
}
else if (theKeyword.wordMetadata.hasFlag(EdgePageWordFlags.SiteAdjacent)) {
return totalFactor * 0.65;
}
else if (theKeyword.wordMetadata.hasFlag(EdgePageWordFlags.Site)) {
return totalFactor * 0.7;
}
return totalFactor;
}
private double calculateTermCoherencePenalty(SearchResultsKeywordSet keywordSet, double f) {
long maskDirect = ~0;
long maskAdjacent = ~0;
byte excludeMask = (byte) (EdgePageWordFlags.Title.asBit() | EdgePageWordFlags.Subjects.asBit() | EdgePageWordFlags.Synthetic.asBit());
for (var keyword : keywordSet.keywords) {
for (var keyword : keywordSet) {
var meta = keyword.wordMetadata;
long positions;