Skip to content

test(audience): add classifier tests and pilot key list for Step 3 - #64

Open
shoaib-inamdar wants to merge 1 commit into
Open-Book-Genome-Project:mainfrom
shoaib-inamdar:pilot/audience-step3-tests
Open

shoaib-inamdar wants to merge 1 commit into
Open-Book-Genome-Project:mainfrom
shoaib-inamdar:pilot/audience-step3-tests

Conversation

@shoaib-inamdar

@shoaib-inamdar shoaib-inamdar commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds the test suite and pilot key list for Issue #62 (Step 3 — Pilot Run).

No production code changed. This PR adds two new files only.


Files Added

tests/test_audience_classify.py — 41 tests, all pass ✅

Mirrors the structure of test_literary_form_classify.py. Covers:

Test class Tests What it checks
TestDirectMappingAudience 18 All 9 vocabulary slugs reachable via mappings.json
TestPatternMatchingAudience 11 Grade-band rules, LCSH suffix, preschool patterns, reading-level exclusion
TestAudienceEdgeCases 9 Empty input, non-strings, case-insensitivity, whitespace, no-match
TestAudienceIntegrationHarryPotter 3 Harry Potter (OL82563W) produces juvenile/children/young-adult tag

Note on test_deduplication: The classifier intentionally returns one TagMatch
per matched subject string (preserving source provenance), consistent with how
genres and literary_form classifiers behave. The test was updated to assert
the correct behavior — unique sources, not unique slugs.

scripts/logs/audience_pilot_keys.txt

50 OL work IDs selected for the Step 3 dry-run, covering a broad spread of
audience slugs: juvenile, children, young-adult, preschool, and academic.


Refs #62 | Parent: #52
cc @mekarpeles @Chisomnwa

Adds 41 tests covering the audience tag type classifier:
- 18 direct-mapping tests (all 9 vocabulary slugs)
- 11 pattern-matching tests (grade bands, LCSH suffix, preschool,
  reading-level exclusion)
- 9 edge-case tests (empty input, non-strings, case-insensitivity,
  whitespace, source provenance, no-match cases)
- 3 Harry Potter integration tests

Also adds scripts/logs/audience_pilot_keys.txt: 50 OL work IDs
for the Step 3 dry-run pilot, covering a broad spread of audience
slugs (juvenile, children, young-adult, preschool, academic).

All 41 tests pass.

Closes Open-Book-Genome-Project#62 | Parent: Open-Book-Genome-Project#52
cc @mekarpeles @Chisomnwa
Copilot AI balanced review requested due to automatic review settings November 7, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@shoaib-inamdar

Copy link
Copy Markdown
Contributor Author

@mekarpeles , @Chisomnwa , I have done the Step 3 , Let me know if any changes are needed

@Chisomnwa

Chisomnwa commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @shoaib-inamdar, thanks for putting this together and for adding the Audience classifier tests. I compared it with the Step 3 issue and the genre pilot in PR #44. This is a useful start, but this PR doesn’t yet show that the 50-work backfill pilot was run, so I can’t sign off on Step 3 or move us to Step 4 yet.

Could you update the PR with the pilot process and results described in Issue #62? In particular:

  1. Please keep this PR focused on the pilot results. The existing scripts/backfill_tags.py is the shared script for running the backfill; we don’t need a new pilot script or classifier test file in this PR. Please remove tests/test_audience_classify.py and scripts/logs/audience_pilot_keys.txt from the PR. The 50-key list is temporary input for the run, and Issue #62 names test_folder/pilot_audience_work_keys.txt as its location. Please don’t commit that temporary file; include the selected Work links/keys and how you chose them in the results instead, so the sample is still reviewable.

  2. Run the 50-key command in dry-run mode first. Please include the exact command and a short summary of how many works were processed and matched, the audience tags proposed, and any errors or retries.

  3. Before writing to production, confirm the audience backfill fix in PR #61 is merged and the audiences field and mapping updates are ready. Then run the same command for only those 50 works without --dry-run, and report the results.

  4. Check a few representative Works on Open Library and link them here. For each, show the expected audience tag and confirm it was saved under the Work’s audiences field. Please finish with the overall result and whether you recommend moving to Step 4, following the evidence and verification style in PR #44.

Also, please change “Closes #62” to “Refs #62” for now, so this PR doesn’t close the Step 3 issue before the pilot results are reviewed. Once the run and checks are documented, I’ll review it with you and we can decide whether to move to Step 4.

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.

3 participants