(index) Adding a few experimental relevance signals

This commit is contained in:
Viktor Lofgren 2024-08-02 20:26:07 +02:00
parent 57929ff242
commit d8a99784e5
2 changed files with 16 additions and 1 deletions

View File

@ -216,6 +216,9 @@ public class IndexResultScoreCalculator {
int bestCoherenceTitle = coherences.testOptional(positions, spans.title);
int bestCoherenceHeading = coherences.testOptional(positions, spans.heading);
boolean allInTitle = coherences.allOptionalInSpan(positions, spans.title);
boolean allInHeading = coherences.allOptionalInSpan(positions, spans.heading);
float[] weightedCounts = new float[compiledQuery.size()];
int firstPosition = Integer.MAX_VALUE;
@ -255,7 +258,9 @@ public class IndexResultScoreCalculator {
+ bestCoherenceAll
+ bestCoherenceTitle
+ bestCoherenceHeading
+ numCoherenceAll / 4.;
+ numCoherenceAll / 4.
+ (allInTitle ? 5.0 : 0)
+ (allInHeading ? 2.5 : 0);
double tcfAvgDist = rankingParams.tcfAvgDist * (1.0 / calculateAvgMinDistance(positionsQuery, ctx));
double tcfFirstPosition = rankingParams.tcfFirstPosition * (1.0 / Math.max(1, firstPosition));

View File

@ -73,6 +73,16 @@ public class TermCoherenceGroupList {
return best;
}
public boolean allOptionalInSpan(CodedSequence[] positions, DocumentSpan span) {
for (var coherenceSet : optionalGroups) {
if (!coherenceSet.test(span, positions)) {
return false;
}
}
return true;
}
public static final class TermCoherenceGroup {
private final int[] offsets;
private final BitSet present;