code / legex /scrapers /base.py
anonymous
[code] Initial release of the code.
6f5156a
raw
history blame contribute delete
806 Bytes
from abc import ABC, abstractmethod
from datetime import date
from legex.models.base import Case
class BaseScraper(ABC):
country: str
@abstractmethod
def scrape(
self,
start_date: date | None = None,
end_date: date | None = None,
) -> list[Case]:
pass
@staticmethod
def civil_filter(cases: list[Case]) -> list[Case]:
return list(cases)
@staticmethod
def enrich(cases: list[Case]) -> list[Case]:
"""Post-sampling enrichment hook — runs on the 130 sampled cases only.
Default is a no-op. Scrapers that need expensive per-case work
(e.g. downloading PDFs and extracting text) override this so the cost is
paid only for the sampled set, not the full corpus.
"""
return list(cases)