import json from pathlib import Path from typing import Dict def load(dataset_path: Path) -> Dict: """ Load a JSON file into a dictionary. Args: dataset_path (Path): Path to the JSON file to be loaded. Returns: Dict: The contents of the JSON file as a dictionary. Raises: FileNotFoundError: If the file does not exist. ValueError: If the file is not valid JSON. """ if not dataset_path.exists(): raise FileNotFoundError(f"The file {dataset_path} does not exist.") try: with dataset_path.open("r", encoding="utf-8") as file: data = json.load(file) except json.JSONDecodeError as e: raise ValueError(f"Failed to parse JSON from {dataset_path}: {e}") return data