import json
from pathlib import Path


def load_reviews(path: str | Path):
    path = Path(path)
    reviews = []

    with path.open("r", encoding="utf-8") as f:
        for line_number, line in enumerate(f, start=1):
            if not line.strip():
                continue

            item = json.loads(line)

            if "id" not in item or "feedback" not in item:
                raise ValueError(f"Invalid review at line {line_number}")

            reviews.append(item)

    return reviews
