Skip to content

Add literary_form migration bot#446

Open
modi02 wants to merge 4 commits into
internetarchive:masterfrom
modi02:tags/literary-form-migration
Open

Add literary_form migration bot#446
modi02 wants to merge 4 commits into
internetarchive:masterfrom
modi02:tags/literary-form-migration

Conversation

@modi02
Copy link
Copy Markdown

@modi02 modi02 commented Apr 16, 2026

literary_form migration bot for the Tag Cleanup GSoC project.

This implements the first stage of the genre taxonomy work: classifying Open Library works as Fiction or Nonfiction based on existing subject strings.

Files:

  • migrate_subjects.py - classification script with conflict resolution logic
  • mappings/literary_form.json - subject string to literary_form mappings
  • mappings/droppable.json - noise strings to strip before classification
  • literary_form_dry_run.jsonl - dry-run output on 100 works (awaiting mentor review)
  • README.md - full documentation and design decisions

Coverage: 29.26% of full corpus (11.9M works) based on initial analysis of 40.79M works dump.

Dry-run results: 97 Fiction, 3 Nonfiction on 100 test works. Both Nonfiction results manually verified as correct (Richard Jefferies biography, Nobel Peace Prize winners biography).

Next steps: Awaiting mentor review of dry-run JSONL before any production writes. @hornc review required before bulk migration (>100 records).

cc @mekarpeles

modi02 and others added 4 commits April 17, 2026 03:50
- Add general fiction, short story, fictitious works as Fiction mappings
- Add biographical, autobiographical as Nonfiction mappings
- Remove texts from literary_form.json (conflict with droppable.json)
- Add texts back to droppable.json as noise entry
- Fix missing LCSH '--' suffix extraction in classify_subject()
  e.g. 'Pirates--Fiction' now correctly resolves to Fiction
- Add 33-test suite covering all new mappings, conflict resolution,
  droppable behavior, case insensitivity, and LCSH patterns
@modi02
Copy link
Copy Markdown
Author

modi02 commented Apr 20, 2026

Pushed an update today:
Mappings expanded (literary_form.json): added general fiction, short story, fictitious works, biographical, autobiographical. Removed texts (was conflicting with droppable.json).
Bug fix (migrate_subjects.py): LCSH -- suffix extraction was missing entirely from classify_subject(). Strings like Pirates--Fiction were falling through to unmapped instead of resolving to Fiction. Fixed by adding the suffix split logic after the direct match check.
Tests added (tests/test_literary_form.py): 33 tests covering all new mappings, LCSH patterns, conflict resolution, droppable behavior, and case insensitivity. All 33 pass.

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.

1 participant