Documentation
¶
Overview ¶
Package wikidata resolves a Work's creators to Wikidata entities and caches their EXPLICITLY-STATED demographic claims as enrichment statements -- the creator-demographics half of the diversity-audit feature.
The contract, in order of importance:
- No name inference, ever. Resolution goes ISBN -> edition (P212/P957) -> work (P629) -> author (P50): every hop is a cataloged identifier or an explicit Wikidata statement. A creator's name is never matched against anything, and a work without a resolvable identifier yields nothing.
- Explicit claims only, with provenance. Only the values Wikidata states outright for P21 (sex or gender), P27 (country of citizenship), P91 (sexual orientation), and P172 (ethnic group) are recorded, each as the claim's own entity URI plus label, alongside the QID it came from, what identifier matched it, and the retrieval date. Birth/death dates are deliberately not fetched.
- Aggregate use. These statements exist so a collection-level audit can report distributions with coverage; they are enrichment-graph data, not display fields, and the projector does not surface them on work pages.
Coverage will be partial and skewed (Wikidata's own coverage is); the audit reading this data is responsible for reporting match rate and unknowns first. Statements land in the enrichment:wikidata graph, dropped and replaced on each run, so a re-run refreshes and a removed claim upstream disappears here too.
Index ¶
Constants ¶
const DefaultEndpoint = "https://query.wikidata.org/sparql"
DefaultEndpoint is the public Wikidata Query Service SPARQL endpoint.
const Name = "wikidata"
Name is the enrichment source name; statements land in enrichment:wikidata.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Enricher ¶
type Enricher struct {
// contains filtered or unexported fields
}
Enricher resolves creators via the Wikidata Query Service.
func (*Enricher) Enrich ¶
func (e *Enricher) Enrich(ctx context.Context, works []ingest.WorkSummary) ([]ingest.Enrichment, error)
Enrich resolves each Work's creators by cataloged identifiers, in two passes: author authority IDs first (VIAF/LCNAF/ISNI/ORCID -> the direct wdt:P214/P244/P213/P496 lookups -- indexed exact matches, the high-recall path), then ISBN -> edition -> author for works the first pass left unmatched. Works with no resolvable identifier, or whose identifiers Wikidata does not know, are absent from the result -- RunEnrich leaves them untouched, and the audit reports them as unmatched rather than guessing. Never a name, in either pass.
func (*Enricher) RunStats ¶ added in v0.185.0
func (e *Enricher) RunStats() ingest.EnrichStats
RunStats implements ingest.StatsReporter: the run's counters. Safe to call while Enrich runs -- counters advance per batch, which is what makes a polled progress display possible.
type Option ¶
type Option func(*Enricher)
Option configures the enricher.
func WithClient ¶
WithClient injects the HTTP client (tests; a caller with its own limits).
func WithEndpoint ¶
WithEndpoint points at a different SPARQL endpoint (a mirror, a test stub).
func WithLogger ¶ added in v0.185.0
WithLogger wires progress logging: per-batch INFO lines, retry and skipped-batch WARNs -- a multi-minute synchronous run must be observable from the server log. Nil (the default) logs nothing.
func WithRetryBase ¶ added in v0.181.1
WithRetryBase overrides the first retry pause (tests use 0).