metadatatools

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: BSD-3-Clause Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Metadata Tools

This project was inspired by the idutils Python package. This package is not a port of the Python idutils. This project focuses on the identifiers Caltech Library needs for the COLD project.

For each supported identifier three types of methods are implemented.

normalization : this will return a valid identifier into a regularize format for validation and verification

validation : this checks if the form of the identifier string makes sense, e.g. does it look like an ORCID is expected to look?

verification : verification checks with the authoritative organization to see if data is available for the identifier. In most cases that means the organizations that supports creating and managing the identifier (e.g. orcid.org, isni.org, ror.org).

Supported identifiers

  • ArXiv ID
  • DOI
  • ISBN
  • ISSN
  • ISNI
  • ORCID
  • PMID
  • PMCID
  • RAiD
  • ROR
  • LCNAF
  • VIAF
  • SNAC

USAGE

There are three ways to use Metadata Tools. The first is via the command line program mdtools. This simple command line program accepts three parameters, ACTION, ID_TYPE and IDENTIFIER. See man page for details. An ACTION can be one of three things, "normalize", "validate" and "verify". The second parameter is one of the types listed above. The final parameter the identifier value. "normalize" will accept an identifier in a common format variation and return a consisantly formated result. E.g. The ORCID "https://orcid.org/0000-0003-0900-6903" will be normalize to "0000-0003-0900-6903" where as an ROR of "05dxps055" will normalize to "https://ror.org/05dxps055". The normalization appplied reflects the typical way we handle the idenfier formatting in Caltech Library's repository systems.

"validate" will check of the identifier matches and expected form. E.g. An order looks like four digits dash four digits dash four digits dash for digits. There is some check summing also applied to validate the sequence (like with ISNI). Validate will make sure the supplied identifier confirms to those types of rules. It does not verify the value with the originating organization.

"verify" will validate the identifier supplied then check via a web service if the identifier is known to the sponsoring organization or authority control. As a result it requires network access and will fail if the sponsoring organization's website or service is unavailable.

Both "validate" and "verfiy" return booleaning true if everything checks out and false otherwise. The command line program mtd will also return a non-zero exit code if the validation or verification fails.

The second way Metadata Tools can be use is as a ESM TypeScript module. The TypeScript module you can use from Deno. The latest version of the Metadata Tools module can be found at https://github.com/caltechlibrary/metadatatools/latest/release and on the Caltech Library development group's GitHub website, https://caltechlibrary.github.io/metadatatools/mod.ts. The mod.ts file will pull in the whole set of identifier normalization, validation and verification routines.

Installation

The command line program can be installed using installer scripts hosted at https://caltechlibrary.github.io/metadatatools. See INSTALL.md for details.

While Metadata Tools should be considered experimental binaries are being provided for macOS (x86_64 and M series processes), Windows 11 running on x86_64 processors and for Linux on x86_64 and aarch64 processesor.

License

See LICENSE for license details.

Documentation

Index

Constants

View Source
const (
	// Version number of release
	Version = "0.1.1"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2026-06-11"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "5bbf50d"
	LicenseText = `` /* 1525-byte string literal not displayed */

)
View Source
const ARXIVPattern = `^arxiv:(\d{4}\.\d{4,5}(v\d+)?|[a-z\-]+/\d{7}(v\d+)?)$`

ARXIVPattern matches a normalized arXiv identifier in either the new (YYMM.NNNNN) or old (archive/YYMMNNN) form, with an optional version suffix.

View Source
const DOIPattern = `^https://doi\.org/10\.\d{4,9}/[^\s]+$`

DOIPattern is the regular expression pattern matching a normalized (extended/full URL) DOI.

View Source
const DOIPrefix = "https://doi.org/"

DOIPrefix is the canonical resolver URL prefix for a DOI.

View Source
const DOIShortPattern = `^10\.\d{4,9}/[^\s]+$`

DOIShortPattern is the regular expression pattern matching a normalized short-form (bare) DOI.

View Source
const EMAILPattern = `^(?:"?([^"]*)"?\s)?(?:<?(.+@[^>]+)>?)$`

EMAILPattern is the regular expression pattern matching a normalized email address.

View Source
const ISBN10Pattern = `^(?:\d[ |-]?){9}[\d|X]$`

ISBN10Pattern matches an ISBN-10 with optional space or hyphen separators between digits.

View Source
const LCNAFPattern = `^[a-zA-Z0-9]+$`

LCNAFPattern matches a normalized Library of Congress Name Authority File identifier.

View Source
const MDToolsHelpText = `` /* 1444-byte string literal not displayed */

MDToolsHelpText holds the man page style documentation for the mdtools command line program.

View Source
const NewARXIVPattern = `^arxiv:\d{4}\.\d{4,5}(v\d+)?$`

NewARXIVPattern matches a normalized arXiv identifier in the new (post March 2007) YYMM.NNNNN form.

View Source
const ORCIDPattern = `^(\d{4}-\d{4}-\d{4}-\d{3}[\dX])$`

ORCIDPattern matches a normalized ORCID iD.

View Source
const OldARXIVPattern = `^arxiv:[a-z\-]+/\d{7}(v\d+)?$`

OldARXIVPattern matches a normalized arXiv identifier in the old (pre March 2007) archive/YYMMNNN form.

View Source
const PMCIDPattern = `^PMC\d+$`

PMCIDPattern matches a normalized PubMed Central identifier.

View Source
const PMIDPattern = `^[0-9]+$`

PMIDPattern matches a normalized PubMed identifier (digits only).

View Source
const RAiDPattern = `^https://raid\.org/10\.\d{4,9}/[^\s]+$`

RAiDPattern is the regular expression pattern matching a normalized (extended/full URL) RAiD.

RAiDs are issued as DOIs via DataCite, so this is the same shape as DOIPattern (10.<4-9 digit registrant code>/<suffix>) under the raid.org resolver host. See dev-notes/decisions_RAiD_support.md D8.

View Source
const RAiDPrefix = "https://raid.org/"

RAiDPrefix is the canonical resolver URL prefix for a RAiD.

View Source
const RAiDShortPattern = `^10\.\d{4,9}/[^\s]+$`

RAiDShortPattern is the regular expression pattern matching a normalized short-form (bare) RAiD. Identical to DOIShortPattern, since RAiDs are DOI-shaped. See dev-notes/decisions_RAiD_support.md D8.

View Source
const RORPattern = `^https://ror\.org/0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$|^0[a-hj-km-np-tv-z|0-9]{6}[0-9]{2}$`

RORPattern matches a normalized ROR identifier, either as a full https://ror.org/ URL or as a bare ROR ID.

View Source
const RORPrefix = "https://ror.org/"

RORPrefix is the canonical URL prefix for a ROR identifier.

View Source
const SNACPattern = `^\d+$`

SNACPattern matches a normalized SNAC identifier, which is numeric.

View Source
const TELPattern = `^\+?(\d{1,3})?[-.\s]?(\(?\d{1,4}\)?)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$`

TELPattern is a permissive regular expression pattern for telephone numbers in a variety of common formats.

View Source
const VIAFPattern = `^\d+$`

VIAFPattern matches a normalized VIAF identifier, which is numeric.

Variables

This section is empty.

Functions

func FmtHelp

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

func GetObject

func GetObject(identifier string, u string, validate ValidatorFunc) (interface{}, bool)

GetObject is a generic retrieval of a JSON value from a remote source. It validates identifier before fetching u. The second return value is false if validation fails, the request fails, the response is not a 2xx, or the response body cannot be parsed as JSON. The decoded value may be a map, slice, or scalar depending on what u returns.

func GetObjectDOI

func GetObjectDOI(doi string) (interface{}, bool)

GetObjectDOI retrieves a DOI record from CrossRef, falling back to DataCite if CrossRef does not have it.

Example:

doi := "10.22002/bv2pv-2b295"
obj, ok := GetObjectDOI(doi)
if !ok {
    fmt.Printf("%s did not return an object, maybe it is not valid\n", doi)
} else {
    fmt.Printf("%s returns an object %v\n", doi, obj)
}

func GetObjectISBN

func GetObjectISBN(isbn string) (interface{}, bool)

GetObjectISBN retrieves an ISBN record from Open Library.

func NormalizeArXivID

func NormalizeArXivID(arxivID string) string

NormalizeArXivID trims whitespace from arxivID and lower cases it.

Example:

id := NormalizeArXivID("ARXIV:2412.03631")
// id == "arxiv:2412.03631"

func NormalizeDOI

func NormalizeDOI(doi string) string

NormalizeDOI normalizes a DOI to its extended (full URL) form.

Example:

doi := NormalizeDOI("10.22002/bv2pv-2b295")
// doi == "https://doi.org/10.22002/bv2pv-2b295"

func NormalizeDOIShort

func NormalizeDOIShort(doi string) string

NormalizeDOIShort normalizes a DOI to its short form by removing extraneous characters and enforcing lowercase.

Example:

doi := NormalizeDOIShort("https://www.doi.org/10.22002/bv2pv-2b295")
// doi == "10.22002/bv2pv-2b295"

func NormalizeEAN

func NormalizeEAN(ean string) string

NormalizeEAN trims whitespace from ean and removes any non-digit characters.

Example:

ean := NormalizeEAN("9780201544282")
// ean == "9780201544282"

func NormalizeEMAIL

func NormalizeEMAIL(email string) string

NormalizeEMAIL trims whitespace from email and removes any internal whitespace.

Example:

email := NormalizeEMAIL("  jane.doe@example.edu ")
// email == "jane.doe@example.edu"

func NormalizeFundRefID

func NormalizeFundRefID(id string) string

NormalizeFundRefID trims whitespace from id and lower cases it.

Example:

id := NormalizeFundRefID("10.13039/100000001")
// id == "10.13039/100000001"

func NormalizeISBN

func NormalizeISBN(isbn string) string

NormalizeISBN removes hyphens and whitespace from isbn and reformats 10 or 13 digit ISBNs with hyphens.

Example:

isbn := NormalizeISBN("978-3-16-148410-0")
// isbn == "978-3-16-14841-00"

func NormalizeISNI

func NormalizeISNI(isni string) string

NormalizeISNI removes whitespace and hyphens from isni and reformats it as four space-separated groups of four digits.

func NormalizeISSN

func NormalizeISSN(issn string) string

NormalizeISSN removes any non-digit characters from issn and reformats it as NNNN-NNNN.

Example:

issn := NormalizeISSN("1058-6180")
// issn == "1058-6180"

func NormalizeLCNAF

func NormalizeLCNAF(id string) string

NormalizeLCNAF trims whitespace from id.

func NormalizeORCID

func NormalizeORCID(orcid string) string

NormalizeORCID strips whitespace, hyphens, and any "https://orcid.org/" prefix from orcid, then formats the remaining 16 characters as four hyphen-separated groups of four.

func NormalizePMCID

func NormalizePMCID(pmcid string) string

NormalizePMCID trims whitespace from pmcid, upper cases it, and adds a leading "PMC" if pmcid does not already start with one.

func NormalizePMID

func NormalizePMID(pubMedID string) string

NormalizePMID removes a leading "pmid:" label and surrounding whitespace from pubMedID.

func NormalizeRAiD

func NormalizeRAiD(raid string) string

NormalizeRAiD normalizes a RAiD to its extended (full URL) form.

Example:

raid := NormalizeRAiD("10.26259/0e59e9a5")
// raid == "https://raid.org/10.26259/0e59e9a5"

func NormalizeRAiDShort

func NormalizeRAiDShort(raid string) string

NormalizeRAiDShort normalizes a RAiD to its short form by removing extraneous characters and enforcing lowercase.

Example:

raid := NormalizeRAiDShort("https://raid.org/10.26259/0e59e9a5")
// raid == "10.26259/0e59e9a5"

func NormalizeROR

func NormalizeROR(ror string) string

NormalizeROR trims whitespace from ror, lower cases it, and ensures it has the RORPrefix.

func NormalizeSNAC

func NormalizeSNAC(id string) string

NormalizeSNAC trims whitespace from id.

func NormalizeTEL

func NormalizeTEL(tel string) string

NormalizeTEL formats tel based on the number of digits it contains. If the digit count does not match a recognized length, tel is returned unchanged.

func NormalizeUUID

func NormalizeUUID(uuid string) string

NormalizeUUID lower cases uuid and removes any whitespace.

func NormalizeVIAF

func NormalizeVIAF(id string) string

NormalizeVIAF trims whitespace from id.

func ValidateArXivID

func ValidateArXivID(arxivID string) bool

ValidateArXivID normalizes arxivID then validates it against ARXIVPattern.

func ValidateDOI

func ValidateDOI(doi string) bool

ValidateDOI validates the extended (full URL) form of a DOI.

func ValidateDOIShort

func ValidateDOIShort(doi string) bool

ValidateDOIShort validates the short (bare) form of a DOI.

func ValidateEAN

func ValidateEAN(ean string) bool

ValidateEAN validates an EAN (International Article Number, European Article Number, Japanese Article Number) in either its 13 digit or 8 digit form.

func ValidateEMAIL

func ValidateEMAIL(email string) bool

ValidateEMAIL validates the form of email after normalizing it.

func ValidateFundRefID

func ValidateFundRefID(id string) bool

ValidateFundRefID normalizes id then validates it against fundRefPattern.

func ValidateISBN

func ValidateISBN(isbn string) bool

ValidateISBN validates isbn as either an ISBN-10 or ISBN-13.

func ValidateISNI

func ValidateISNI(isni string) bool

ValidateISNI validates the form and checksum of isni.

func ValidateISSN

func ValidateISSN(issn string) bool

ValidateISSN normalizes issn then validates its checksum digit.

func ValidateLCNAF

func ValidateLCNAF(id string) bool

ValidateLCNAF normalizes id then validates it against LCNAFPattern.

func ValidateORCID

func ValidateORCID(orcid string) bool

ValidateORCID normalizes orcid, checks its form against ORCIDPattern, and verifies its ISO 7064 Mod 11-2 checksum digit.

func ValidatePMCID

func ValidatePMCID(pmcid string) bool

ValidatePMCID normalizes pmcid then validates it against PMCIDPattern.

func ValidatePMID

func ValidatePMID(pubMedID string) bool

ValidatePMID normalizes pubMedID then validates it against PMIDPattern.

func ValidateRAiD

func ValidateRAiD(raid string) bool

ValidateRAiD validates the extended (full URL) form of a RAiD.

func ValidateRAiDShort

func ValidateRAiDShort(raid string) bool

ValidateRAiDShort validates the short (bare) form of a RAiD.

func ValidateROR

func ValidateROR(ror string) bool

ValidateROR normalizes ror then validates it against RORPattern.

func ValidateSNAC

func ValidateSNAC(id string) bool

ValidateSNAC normalizes id then validates it against SNACPattern.

func ValidateTEL

func ValidateTEL(tel string) bool

ValidateTEL validates tel against TELPattern.

func ValidateUUID

func ValidateUUID(uuid string) bool

ValidateUUID normalizes uuid then validates its form.

func ValidateVIAF

func ValidateVIAF(id string) bool

ValidateVIAF normalizes id then validates it against VIAFPattern.

func VerifyArXivID

func VerifyArXivID(arxiv string) bool

VerifyArXivID verifies an arXiv identifier exists via the export.arxiv.org API. The identifier is normalized before verifying.

func VerifyDOI

func VerifyDOI(doi string) bool

VerifyDOI verifies a DOI is registered via the DOI handle system (doi.org).

Example:

doi := "10.22002/bv2pv-2b295"
if VerifyDOI(doi) {
    fmt.Printf("%s appears valid\n", doi)
} else {
    fmt.Printf("%s is not valid\n", doi)
}

func VerifyFundRefID

func VerifyFundRefID(id string) bool

VerifyFundRefID verifies a FundRef ID exists via CrossRef's API. The identifier is normalized before verifying.

func VerifyISBN

func VerifyISBN(isbn string) bool

VerifyISBN verifies an ISBN exists via Open Library. The identifier is normalized before verifying.

func VerifyISNI

func VerifyISNI(isni string) bool

VerifyISNI verifies an ISNI exists via isni.org. The identifier is normalized before verifying.

func VerifyISSN

func VerifyISSN(issn string) bool

VerifyISSN verifies an ISSN exists via portal.issn.org. The identifier is normalized before verifying.

func VerifyIdentifier

func VerifyIdentifier(identifier string, u string, validate ValidatorFunc) bool

VerifyIdentifier attempts to retrieve an object from a remote source. It validates identifier first; if validate returns false, or the GET to u fails or does not return a 2xx status, it returns false.

func VerifyLCNAF

func VerifyLCNAF(id string) bool

VerifyLCNAF verifies an LCNAF ID exists via id.loc.gov. The identifier is normalized before verifying.

func VerifyORCID

func VerifyORCID(orcid string) bool

VerifyORCID verifies an ORCID iD exists via orcid.org. The identifier is normalized before verifying.

func VerifyPMCID

func VerifyPMCID(pmcid string) bool

VerifyPMCID verifies a PMCID exists via www.ncbi.nlm.nih.gov/pmc. The identifier is normalized before verifying.

func VerifyPMID

func VerifyPMID(pmid string) bool

VerifyPMID verifies a PMID exists via pubmed.ncbi.nlm.nih.gov. The identifier is normalized before verifying.

func VerifyROR

func VerifyROR(ror string) bool

VerifyROR verifies a ROR identifier exists via ror.org. The identifier is normalized (and resolves directly to its ror.org URL) before verifying.

func VerifySNAC

func VerifySNAC(id string) bool

VerifySNAC verifies a SNAC ID exists via the SNAC Cooperative website. The identifier is normalized before verifying.

func VerifyVIAF

func VerifyVIAF(id string) bool

VerifyVIAF verifies a VIAF ID exists via viaf.org. The identifier is normalized before verifying.

Types

type NormalizorFunc

type NormalizorFunc func(string) string

NormalizorFunc returns an identifier in a regularized format.

type ValidatorFunc

type ValidatorFunc func(string) bool

ValidatorFunc checks if the form of an identifier string is valid.

type VerifyFunc

type VerifyFunc func(string) bool

VerifyFunc checks with an authoritative source that an identifier exists.

Directories

Path Synopsis
cmd
mdtools command
mdtools is a command line tool for normalizing, validating and verifying scholarly and bibliographic identifiers (ArXiv, DOI, ISBN, ORCID, ROR, etc.).
mdtools is a command line tool for normalizing, validating and verifying scholarly and bibliographic identifiers (ArXiv, DOI, ISBN, ORCID, ROR, etc.).

Jump to

Keyboard shortcuts

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