From 7d1ef08a0f8450c84ea1a0af4cabdb1c6cefda7c Mon Sep 17 00:00:00 2001 From: Viktor Lofgren Date: Mon, 25 Nov 2024 17:40:15 +0100 Subject: [PATCH] (index) Correct ranking bonus for external linktext appearnces --- .../index/results/IndexResultScoreCalculator.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/index/java/nu/marginalia/index/results/IndexResultScoreCalculator.java b/code/index/java/nu/marginalia/index/results/IndexResultScoreCalculator.java index 1c6c7f8b..7bd08784 100644 --- a/code/index/java/nu/marginalia/index/results/IndexResultScoreCalculator.java +++ b/code/index/java/nu/marginalia/index/results/IndexResultScoreCalculator.java @@ -352,7 +352,7 @@ public class IndexResultScoreCalculator { case ANCHOR -> 0.2f; case NAV -> 0.1f; case CODE -> 0.25f; - case EXTERNAL_LINKTEXT -> 1.0f; + case EXTERNAL_LINKTEXT -> 2.0f; case BODY -> 1.0f; default -> 0.0f; }; @@ -365,7 +365,7 @@ public class IndexResultScoreCalculator { case ANCHOR -> 0.2f; case NAV -> 0.1f; case CODE -> 0.25f; - case EXTERNAL_LINKTEXT -> 1.0f; + case EXTERNAL_LINKTEXT -> 2.0f; case BODY -> 0.25f; default -> 0.0f; }; @@ -387,9 +387,9 @@ public class IndexResultScoreCalculator { score += 4; // If the title is a single word and the same as the query, we give it a verbatim bonus } - var atagSpan = spans.getSpan(HtmlTag.ANCHOR); - if (atagSpan.length() == fullGroup.size - && atagSpan.containsRangeExact(fullGroupIntersections, fullGroup.size)) + var extLinkSpan = spans.getSpan(HtmlTag.EXTERNAL_LINKTEXT); + if (extLinkSpan.length() == fullGroup.size + && extLinkSpan.containsRangeExact(fullGroupIntersections, fullGroup.size)) { score += 4; // Add additional bonus if there's a single-word atag span } @@ -405,8 +405,8 @@ public class IndexResultScoreCalculator { } // Bonus if there's a perfect match with an atag span - var atagSpan = spans.getSpan(HtmlTag.ANCHOR); - if (atagSpan.length() == fullGroup.size && atagSpan.containsRangeExact(fullGroupIntersections, fullGroup.size)) + var extLinkSpan = spans.getSpan(HtmlTag.EXTERNAL_LINKTEXT); + if (extLinkSpan.length() == fullGroup.size && extLinkSpan.containsRangeExact(fullGroupIntersections, fullGroup.size)) { score += 1; }