skos

package
v0.32.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package skos reads a SKOS concept scheme (a controlled vocabulary such as homosaurus or LCSH published as RDF) and crosswalks each skos:Concept to a MARC authority record. It parses the common RDF serializations via the rdf package and maps prefLabel/altLabel/broader/narrower/related onto the MARC 1xx/4xx/5xx authority structure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Records

func Records(concepts []Concept) []*codex.Record

Records crosswalks a slice of concepts to authority records, in order.

Types

type Concept

type Concept struct {
	URI      string  // the concept IRI (subject)
	ID       string  // dc:identifier, or the IRI's last path segment
	Scheme   string  // skos:inScheme target IRI; optional
	Pref     []Label // skos:prefLabel (one per language)
	Alt      []Label // skos:altLabel
	Broader  []Ref   // skos:broader
	Narrower []Ref   // skos:narrower
	Related  []Ref   // skos:related
	Notes    []Label // skos:scopeNote and rdfs:comment
}

Concept is one skos:Concept with the fields the authority crosswalk uses.

func Parse

func Parse(data []byte) ([]Concept, error)

Parse reads a SKOS concept scheme from RDF bytes (serialization autodetected) and returns its concepts sorted by id. broader/narrower/related references are resolved to the target concept's preferred label when the target is in the set.

func Read

func Read(r io.Reader) ([]Concept, error)

Read parses a SKOS concept scheme from r. It is Parse over the whole stream.

func (Concept) PrefLabel

func (c Concept) PrefLabel() string

PrefLabel returns the concept's English-preferred preferred label, falling back to the first prefLabel in document order, or "" when none is present.

func (Concept) Record

func (c Concept) Record() *codex.Record

Record crosswalks the concept to a MARC 21 authority record: the concept IRI is a 024 URI, the English preferred label the 150 established heading, other labels 450 see-from tracings, and broader/narrower/related concepts 550 see-also tracings ($w g/h for the hierarchy) carrying the target's label and IRI. Scope notes and comments become 680 public notes.

type Label

type Label struct {
	Text string
	Lang string // "" when the source literal had no language tag
}

Label is a text value with an optional BCP-47 language tag.

type Ref

type Ref struct {
	URI   string
	ID    string
	Label string // "" when the target concept is not in the parsed set
}

Ref is a reference from one concept to another: the target IRI, its short id, and its preferred label resolved against the scheme when the target is present.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL