From 424e5dfc612954f17704ddf6dba00898a4b8d6c6 Mon Sep 17 00:00:00 2001 From: kert Date: Tue, 27 Oct 2026 14:34:57 -0400 Subject: [PATCH] feat(bib): route the ML library and the LEAD snowball into Zotero collections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit source:ml-library → ML library / Books | Articles (by ml:book), and source:lead-snowball → LEAD corpus / Cited works. Without a route the sync files items at the top of My Library only (the ML library's first push reported collections: 0). --- src/bib/sync.py | 5 +++++ tests/bib/test_sync_deeper.py | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/bib/sync.py b/src/bib/sync.py index 5de9ac7..81c7886 100644 --- a/src/bib/sync.py +++ b/src/bib/sync.py @@ -474,6 +474,11 @@ def _zotero_collection_path(item: Item) -> list[str]: if guidance: return [*base, guidance] return base + if "source:ml-library" in item.tags: + return ["ML library", "Books" if "ml:book" in item.tags else "Articles"] + if "source:lead-snowball" in item.tags: + # Works the LEAD corpus cites, pulled from open-access sources. + return ["LEAD corpus", "Cited works"] if "source:lead-corpus" in item.tags: # dev/scripts/import_lead_corpus.py: research papers by the topic # folder they were staged in (first lead-topic: tag), dataset diff --git a/tests/bib/test_sync_deeper.py b/tests/bib/test_sync_deeper.py index 3298b63..216c644 100644 --- a/tests/bib/test_sync_deeper.py +++ b/tests/bib/test_sync_deeper.py @@ -248,6 +248,22 @@ class TestCollectionPathEdge: "Measure specifications", ] + def test_ml_library_books_and_articles(self): + book = Source(title="Elements of Statistical Learning") + for t in ("source:ml-library", "ml:book"): + book.add_tag(t) + paper = Source(title="Conformal prediction tutorial") + for t in ("source:ml-library", "ml:article"): + paper.add_tag(t) + assert _zotero_collection_path(book) == ["ML library", "Books"] + assert _zotero_collection_path(paper) == ["ML library", "Articles"] + + def test_lead_snowball_cited_works(self): + item = Source(title="Pope 2004") + item.add_tag("source:lead-snowball") + item.add_tag("lead-topic:risk_adjustment") + assert _zotero_collection_path(item) == ["LEAD corpus", "Cited works"] + def test_oig_no_sector_no_guidance(self): """Line 421: OIG with neither sector nor guidance → base only.""" item = Source(title="OIG doc")