fix: collection field extraction and add regression tests for sort-key and nested layout

This commit is contained in:
marcuspaico
2026-08-14 17:11:47 -07:00
parent f456877b58
commit 221b1f5097
2 changed files with 32 additions and 1 deletions

View File

@@ -23,9 +23,11 @@ def load_bilara_suttas(root: Path) -> Iterator[dict]:
segments = json.loads(f.read_text())
uid = f.name.split("_")[0]
title = next(iter(segments.values()), uid)
# Derive collection from first directory under sutta/ (e.g., an, dn, kn, mn, sn)
collection = f.relative_to(base).parts[0]
yield {
"uid": uid,
"title": title.strip(),
"text": segments_to_text(segments),
"collection": f.parent.name,
"collection": collection,
}