from pathlib import Path
from .base import BaseIngestor
from .pdf_extractor import extract_text_from_pdf
from lexar.chunking.generic_chunker import chunk_generic_text

class JudgmentIngestor(BaseIngestor):
    def ingest(self, pdf_path: Path):
        text = extract_text_from_pdf(pdf_path)
        chunks = chunk_generic_text(text)

        for c in chunks:
            c["metadata"].update({
                "source": "Judgment",
                "document": pdf_path.name
            })

        return chunks
