Skip to content

feat: add gold dataset curation utility, annotation schema, and candidate filtering (#5) - #36

Open
Pranav-0440 wants to merge 1 commit into
PecanProject:mainfrom
Pranav-0440:curate-gold-dataset-issue-5
Open

Pranav-0440 wants to merge 1 commit into
PecanProject:mainfrom
Pranav-0440:curate-gold-dataset-issue-5

Conversation

@Pranav-0440

Copy link
Copy Markdown

Closes #5
Related to #1

Summary

This PR establishes the foundation for the paper-text-annotated gold dataset required for PDF extractor benchmarking (#1) and SAGE extraction evaluation. It delivers an agreed annotation schema, candidate paper filtering from PecanProject/betydata, automated DOI-based PDF acquisition, and validation tooling.

Key Changes

1. Documented Annotation Schema & Architecture (docs/annotation_schema.md)

  • Separation of Concerns: Strictly separates:
    1. Source-Level Paper Provenance (page number, bounding box, table/figure/text locator, verbatim printed text, context notes) compatible with Zotero document annotations and SAGE IR source locators.
    2. Harmonized BETYdb Representation (standardized units, controlled vocabulary, and target BETYdb entity mapping).
  • Zotero Integration: Aligns annotation models with the Zotero direct document annotation API schema (highlight, note, image, page index, bounding rects, and tags).

2. Candidate Filtering Utility (src/curation/filter.py)

  • Automatically ingests citation and relationship tables from PecanProject/betydata (either locally or streamed directly from GitHub).
  • Implements the filtering criteria specified in Curate a paper-text-annotated gold dataset for extraction benchmarking #5:
    • $\ge 2$ observed treatments per paper
    • $\ge 1$ linked management records (managements_treatments)
    • $\ge 1$ trait or yield observations (traitsview)
    • Valid, auto-downloadable DOI
    • Publication year range ($1990 \le \text{Year} \le 2026$, filtering out historical anomalies)
  • Identifies 122 qualifying candidate papers from BETYdb and ranks them by experimental complexity (control group presence, treatment count, management count, and trait observation volume).

3. Open Access PDF Acquisition (src/curation/downloader.py)

  • Resolves paper DOIs to open-access PDF links via OpenAlex and Unpaywall API endpoints.
  • Validates downloaded file integrity using PDF magic byte verification (%PDF-) to prevent saving error HTML or paywall pages.
  • Calculates and stores SHA-256 checksums for reproducibility.

4. Curation CLI (src/curation/cli.py)

Provides three subcommands:

# 1. Filter candidate papers and output manifest
python -m curation.cli filter --limit 25 -o ../data/gold_dataset/manifest.json

# 2. Acquire paper PDFs via open-access DOI resolution
python -m curation.cli download -m ../data/gold_dataset/manifest.json -o docproc/paper --limit 5

# 3. Validate gold annotations against schema
python -m curation.cli validate -a ../data/gold_dataset/sample_gold_annotations.json

5. Datasets & Schemas (data/gold_dataset/)

  • data/gold_dataset/manifest.json: Top 25 candidate papers from BETYdata ready for pilot acquisition.
  • data/gold_dataset/candidates_summary.csv: Tabular overview of candidate metadata, treatments, managements, and species.
  • data/gold_dataset/sample_gold_annotations.json: Verified reference annotations demonstrating verbatim paper provenance linked to harmonized BETYdb targets.

Testing & Verification

  • Added comprehensive unit tests in src/tests/test_curation.py covering:
    • DOI standardization & validation (test_clean_doi)
    • Model serialization and validation (test_gold_annotation_model_validation, test_paper_manifest_serialization)
    • Filtering logic with qualifying and excluded edge cases (test_candidate_filter_*)
    • Downloader magic-byte verification and SHA-256 calculation (test_downloader_*)
    • CLI parser and validation runner (test_cli_*)
  • Ran test suite:
    pytest tests/test_curation.py
    # 10 passed in 0.74s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Curate a paper-text-annotated gold dataset for extraction benchmarking

1 participant