Repository navigation
fix(deep-crawl): FreshnessScorer defaults to the current year - #2427
Open
Siddharth-DWT wants to merge 1 commit into
Open
Siddharth-DWT wants to merge 1 commit into
Siddharth-DWT wants to merge 1 commit into
Conversation
current_year defaulted to a hard-coded 2024, and years after current_year are discarded as invalid, so from 2025 on a URL dated this year scored 0.5, the same as an undated one, while 2024 content scored highest. Default to date.today().year; an explicit current_year still works as before.
SohamKukreti
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @Siddharth-DWT, this is a clean, minimal fix.
Review
- The change is small and does only one thing. If you pass
current_yearyourself, by name or by position, it works the same as before. If you do not pass it, the scorer uses the current year, which fixes #2426. - Saving and loading the config works the same. The default is still not saved, so a loaded scorer uses the current year, not 2024.
test_default_scores_this_year_highestcatches the bug: it fails ondevelopand passes here.- Nit (does not block the merge):
test_explicit_current_year_is_still_honouredmostly repeatstests/general/test_deep_crawl_scorers.py, which already usescurrent_year=2024. You can keep it or remove it.
Testing
- I ran the scorer, filter, deep-crawl and security tests on this branch and on
develop. The results are the same, and the 2 new tests pass. - I ran a live crawl of
https://blog.rust-lang.org/withBestFirstCrawlingStrategyand the defaultFreshnessScorer(). Ondevelop, it took 13 posts from 2024 and 1 from 2023, and every 2026 post scored 0.5. On this branch, it took 14 posts from 2026, each with a score of 1.0.
LGTM. Thanks for the fix!
3 of 6 tasks
Author
|
Thanks for the review, and for checking it on a live crawl. I'll keep |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
FreshnessScorerdefaulted tocurrent_year=2024, and_extract_yeardiscards years aftercurrent_yearas invalid, so from 2025 on a URL dated this year scored 0.5 (the same as an undated URL) while 2024 content scored highest. The default is nowNone, meaningdate.today().year. An explicitcurrent_yearworks as before.Fixes #2426
List of files changed and why
crawl4ai/deep_crawling/scorers.py:current_year: Optional[int] = None, resolved to the current year in__init__; docstring updated.tests/deep_crawling/test_freshness_scorer_current_year.py: new.How Has This Been Tested?
test_default_scores_this_year_highest: with the default, a URL dated this year scores 1.0 and above last year's, an older one and an undated one. Fails ondevelop.test_explicit_current_year_is_still_honoured:FreshnessScorer(current_year=2024)behaves as before.tests/general/test_deep_crawl_scorers.pypasses.Checklist:
Written with AI assistance; I reviewed the change and ran the tests myself.