From 3ee14ae8977330a86116ec34e7921d92de36f75c Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Mon, 2 Aug 2021 16:45:15 +0200 Subject: mapper: add bref, rewo mappers --- skate/cmd/skate-map/main.go | 2 ++ skate/map.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go index a437705..6c61af0 100644 --- a/skate/cmd/skate-map/main.go +++ b/skate/cmd/skate-map/main.go @@ -81,6 +81,8 @@ func main() { "vcns": skate.MapperReleaseResolvedContainerName, "isbn": skate.MapperOpenLibraryReleaseNormalizedISBN, "cdxu": skate.MapperCdxSummary, + "bref": skate.MapperBrefWork, + "rewo": skate.MapperReleaseWork, } if *logFile != "" { f, err := os.OpenFile(*logFile, os.O_CREATE|os.O_APPEND, 0644) diff --git a/skate/map.go b/skate/map.go index 53aed1e..34e2f2c 100644 --- a/skate/map.go +++ b/skate/map.go @@ -394,6 +394,25 @@ func MapperPartial(p []byte) (fields [][]byte, err error) { return nil, nil } +// MapperBrefWork maps bref for comparison with other datasets, +// such as COCI (which uses DOI). +func MapperBrefWork(p []byte) (fields [][]byte, err error) { + var bref BiblioRef + if err := json.Unmarshal(p, &bref); err != nil { + return nil, err + } + return [][]byte{[]byte(bref.SourceWorkIdent), p}, nil +} + +// MapperReleaseWork maps release to work ident. +func MapperReleaseWork(p []byte) (fields [][]byte, err error) { + var release Release + if err := json.Unmarshal(p, &release); err != nil { + return nil, err + } + return [][]byte{[]byte(release.WorkID), p}, nil +} + // sandcrawlerSlugify normalizes a string. func sandcrawlerSlugify(s string) string { slug := strings.ToLower(strings.TrimSpace(s)) -- cgit v1.2.3