lcsh

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Overview

Package lcsh provides methods for working with Library of Congress Subject Heading (LCSH) data.

Index

Constants

View Source
const DATA_GITHUB string = "https://github.com/sfomuseum/go-sfomuseum-libraryofcongress/raw/main/data/lcsh.csv.bz2"

DATA_GITHUB is the URL for the embedded LCSH data included with this package on GitHub.

View Source
const DATA_JSON string = "lcsh.csv.bz2"

DATA_JSON is the name of the embedded LCSH data included with this package.

Variables

This section is empty.

Functions

func IsMultipleCandidates

func IsMultipleCandidates(e error) bool

IsMultipleCandidates returns a boolean value indicating whether 'e' is of type `MultipleCandidates`.

func IsNotFound

func IsNotFound(e error) bool

IsNotFound returns a boolean value indicating whether 'e' is of type `NotFound`.

func NewSubjectHeadingLookup

func NewSubjectHeadingLookup(ctx context.Context, uri string) (libraryofcongress.Lookup, error)

func NewSubjectHeadingLookupWithLookupFunc

func NewSubjectHeadingLookupWithLookupFunc(ctx context.Context, lookup_func SubjectHeadingLookupFunc) (libraryofcongress.Lookup, error)

NewSubjectHeadingLookupWithLookupFunc will return an `lcsh.SubjectHeadingsLookup` instance derived by data compiled using `lookup_func`.

func OpenData added in v0.4.1

func OpenData(ctx context.Context, uri string) (io.ReadCloser, error)

OpenData() returns an `io.ReadCloser` instance containing LCSH data derived from 'uri' which is expected to take the form of:

Types

type MultipleCandidates

type MultipleCandidates struct{ Code string }

type NotFound is a struct for representing LCSH identifiers that return multiple records.

func (MultipleCandidates) Error

func (e MultipleCandidates) Error() string

Error() returns a stringified representation of 'e'.

func (MultipleCandidates) String

func (e MultipleCandidates) String() string

String() returns a stringified representation of 'e'.

type NotFound

type NotFound struct{ Code string }

type NotFound is a struct for representing missing LCSH records.

func (NotFound) Error

func (e NotFound) Error() string

Error() returns a stringified representation of 'e'.

func (NotFound) String

func (e NotFound) String() string

String() returns a stringified representation of 'e'.

type SubjectHeading

type SubjectHeading struct {
	// Id is the unique identifier for this LCSH record.
	Id string `json:"id"`
	// Label is the name (or title) for this LCSH record.
	Label string `json:"label"`
}

SubjectHeading is a struct containing a subset of data for a LCSH record.

func (*SubjectHeading) String added in v0.0.2

func (sh *SubjectHeading) String() string

String() returns the a string-ified representation of the record's Id and Label properties.

type SubjectHeadingLookup

type SubjectHeadingLookup struct {
	libraryofcongress.Lookup
}

func (*SubjectHeadingLookup) Append

func (l *SubjectHeadingLookup) Append(ctx context.Context, data interface{}) error

func (*SubjectHeadingLookup) Find

func (l *SubjectHeadingLookup) Find(ctx context.Context, code string) ([]interface{}, error)

type SubjectHeadingLookupFunc

type SubjectHeadingLookupFunc func(context.Context)

func NewSubjectHeadingLookupFuncWithReader

func NewSubjectHeadingLookupFuncWithReader(ctx context.Context, r io.ReadCloser) SubjectHeadingLookupFunc

NewSubjectHeadingLookup will return an `SubjectHeadingLookupFunc` function instance that, when invoked, will populate an `lcsh.SubjectHeadingsLookup` instance with data stored in `r`. `r` will be closed when the `SubjectHeadingLookupFunc` function instance is invoked. It is assumed that the data in `r` will be formatted in the same way as the procompiled (embedded) data stored in `data/sfomuseum.json`.

Jump to

Keyboard shortcuts

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