Documentation
¶
Overview ¶
Package openlibrary is an offline external-identity enricher: it links a Work to its OpenLibrary work id by exact ISBN match, from a pre-downloaded ISBN -> work index (OpenLibrary publishes bulk dumps, so there is no per-record live API on the ingest path). The OpenLibrary URI is attached as an owl:sameAs outward link in the enrichment graph -- the minted `w…` id stays the primary identity.
Matching is deliberately conservative: only an exact ISBN hit counts, and a Work whose ISBNs resolve to more than one distinct OpenLibrary work is left unlinked rather than guessed, so an ambiguous edition cluster never mints a wrong sameAs.
Index ¶
Constants ¶
const Name = "openlibrary"
Name is the enricher's registry key and enrichment-graph name.
const Scheme = "openlibrary"
Scheme labels the emitted external identities.
Variables ¶
This section is empty.
Functions ¶
func NormalizeISBN ¶
NormalizeISBN keeps only the ISBN's digits (and an X check digit, upper-cased), so the index and a Work's ISBNs compare on the same form regardless of hyphens or spaces. It deliberately does NOT convert between ISBN-10 and ISBN-13: the dump and the catalog should each carry whatever forms they have, and inventing a conversion here would risk a false match.
func ReadEditionsDump ¶
ReadEditionsDump builds an ISBN -> OpenLibrary work URI index from an OpenLibrary editions dump. The dump is the public bulk TSV: each line is type<TAB>key<TAB>revision<TAB>last_modified<TAB>JSON, and the JSON column carries isbn_10 / isbn_13 arrays and a works reference. The reader streams it -- the real dump is multi-GB -- keeping only the ISBN->work mapping.
Conservatism (the enricher's precision starts here): an ISBN that the dump maps to more than one distinct work is dropped from the index entirely, so it can never contribute a false match. An edition with no works, or no ISBNs, is skipped.
Types ¶
type Enricher ¶
type Enricher struct {
// contains filtered or unexported fields
}
Enricher matches Works against an ISBN -> OpenLibrary-work-URI index.
func New ¶
New builds an Enricher over an ISBN -> OpenLibrary work URI index, normalizing its keys. The index is the offline dump's product; how the dump is obtained and read into this map is a separate concern (a follow-up wires the bulk-dump reader), which keeps the matching logic testable without a multi-GB fixture.
func (*Enricher) Enrich ¶
func (e *Enricher) Enrich(ctx context.Context, works []ingest.WorkSummary) ([]ingest.Enrichment, error)
Enrich implements ingest.Enricher: for each Work, the distinct OpenLibrary works its ISBNs resolve to are collected; a single distinct hit becomes an owl:sameAs identity, a conflict (more than one) is skipped, and no hit leaves the Work untouched. Confidence is 1 -- an ISBN match is exact, not scored. The pass is idempotent: RunEnrich drop-and-replaces the enrichment graph each run.