catalogue

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 10 Imported by: 0

README

Classical catalogue ID parser

classical-catalogue-id-parser is a dependency-free Go package for finding and comparing classical-composition catalogue references such as BWV 1007, Hob. XVI:52, and Wq 182/3.

The package embeds a versioned registry of 130 catalogue symbols. It performs no network or filesystem I/O at runtime and has no music-player, search, or scoring concepts in its API.

Usage

package main

import (
	"fmt"

	catalogue "github.com/bagags/classical-catalogue-id-parser"
)

func main() {
	references := catalogue.Parse("Bach: Cello Suite BWV 1007")
	fmt.Println(references)

	sameWork := catalogue.SharedReference(
		"Cello Suite BWV 1007",
		"Bach: bwv 1007 live",
	)
	fmt.Println(sameWork)
}

Parse and SharedReference use the embedded default registry. Default provides its immutable Registry value and metadata, while Decode strictly validates a caller-supplied registry using the same schema and parser.

Parsed Reference fields are normalized comparison identities: symbols use Unicode case folding, marker and identifier letters use ASCII case folding, and permitted marker punctuation is removed. See REGISTRY.md for the complete grammar, normalization rules, version policy, and source provenance.

Extraction compatibility

The parser implementation, registry, and tests were extracted unchanged from music2bb's internal/catalogue package. The required extraction changes are limited to the Go module import path, the registry's repository location, and documentation ownership; parsing and comparison behaviour are unchanged.

License

MIT. See LICENSE.

Documentation

Overview

Package catalogue parses classical-composition catalogue references from a versioned, embedded symbol registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SharedReference

func SharedReference(left, right string) bool

SharedReference uses the validated embedded registry.

Types

type Reference

type Reference struct {
	Symbol     string
	Marker     string
	Identifier string
}

Reference is the normalized identity of one parsed catalogue reference. Identifier includes the marker, if present.

func Parse

func Parse(text string) []Reference

Parse uses the validated embedded registry.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a validated catalogue-symbol registry. Its contents are immutable after Decode returns.

func Decode

func Decode(data []byte) (*Registry, error)

Decode strictly decodes and validates a version-1 registry.

func Default

func Default() *Registry

Default returns the validated embedded registry. Registry methods do not expose mutable internal storage.

func (*Registry) Parse

func (r *Registry) Parse(text string) []Reference

Parse returns all valid catalogue references found in text.

func (*Registry) Revision

func (r *Registry) Revision() int

Revision returns the registry content and provenance revision.

func (*Registry) Schema

func (r *Registry) Schema() int

Schema returns the registry's incompatible-format version.

func (*Registry) SharedReference

func (r *Registry) SharedReference(left, right string) bool

SharedReference reports whether both texts contain the same complete catalogue reference.

func (*Registry) Source

func (r *Registry) Source() Source

Source returns a copy of the registry provenance.

func (*Registry) Symbols

func (r *Registry) Symbols() []string

Symbols returns a caller-owned copy of the canonical symbol list.

type Source

type Source struct {
	URL         string `json:"url"`
	RetrievedAt string `json:"retrieved_at"`
}

Source records where and when a registry revision was audited.

Jump to

Keyboard shortcuts

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