diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-08-02 16:45:15 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-08-02 16:45:15 +0200 |
commit | 3ee14ae8977330a86116ec34e7921d92de36f75c (patch) | |
tree | a113c7b6d32d15a7e98ae421c5fb1c3240ea1be4 | |
parent | e337df94dc3d4e46ffcf30fa84121fc198e8ac88 (diff) | |
download | refcat-3ee14ae8977330a86116ec34e7921d92de36f75c.tar.gz refcat-3ee14ae8977330a86116ec34e7921d92de36f75c.zip |
mapper: add bref, rewo mappers
-rw-r--r-- | skate/cmd/skate-map/main.go | 2 | ||||
-rw-r--r-- | skate/map.go | 19 |
2 files changed, 21 insertions, 0 deletions
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)) |