From 41bb37e7c431dd95def49ebf100f67cab72ee8d7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 6 Jan 2024 18:32:43 +0100 Subject: [PATCH] WIP verify that `siteFrequency` actually does something So far, I seem to be unable to make this work, as it seems that `word_frequency` is always 0 in my tests... Signed-off-by: Johannes Schindelin --- pagefind/features/scoring.feature | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/pagefind/features/scoring.feature b/pagefind/features/scoring.feature index 3320518f..1af65160 100644 --- a/pagefind/features/scoring.feature +++ b/pagefind/features/scoring.feature @@ -54,6 +54,38 @@ Feature: Result Scoring Then The selector "[data-count]" should contain "2 result(s)" Then The selector "[data-result]" should contain "/dog/, /cat/" + Scenario: Results with less-frequent words score higher + When I evaluate: + """ + async function() { + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search(`cat dog`); + + document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); + } + """ + Then There should be no logs + Then The selector "[data-count]" should contain "2 result(s)" + Then The selector "[data-result]" should contain "/dog/, /cat/" + When I evaluate: + """ + async function() { + let pagefind = await import("/pagefind/pagefind.js"); + + let search = await pagefind.search(`cat dog`, { ranking: { siteFrequency: 0.0 } }); + + document.querySelector('[data-count]').innerText = `${search.results.length} result(s)`; + let data = await Promise.all(search.results.map(result => result.data())); + document.querySelector('[data-result]').innerText = data.map(d => d.url).join(', '); + } + """ + Then There should be no logs + Then The selector "[data-count]" should contain "2 result(s)" + # This currently fails... but why? Then The selector "[data-result]" should contain "/cat/, /dog/" + Scenario: Ranking can be configured to stop favoring pages with less words Given I have a "public/index.html" file with the body: """