aboutsummaryrefslogtreecommitdiffstats
path: root/skate
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-07-15 03:47:15 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-07-15 03:47:15 +0200
commit83eea98c43f3ac6076b8aeb985a14f5b168b991e (patch)
tree41f38f37747086e7a9f878d4be7f281fa9fbe630 /skate
parent6e7baa12619e8b51218bcefb2c6dd75525eb7387 (diff)
downloadrefcat-83eea98c43f3ac6076b8aeb985a14f5b168b991e.tar.gz
refcat-83eea98c43f3ac6076b8aeb985a14f5b168b991e.zip
map: add another mapper
Diffstat (limited to 'skate')
-rw-r--r--skate/cmd/skate-map/main.go3
-rw-r--r--skate/map.go17
2 files changed, 17 insertions, 3 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go
index 202f8bd..5b86250 100644
--- a/skate/cmd/skate-map/main.go
+++ b/skate/cmd/skate-map/main.go
@@ -73,7 +73,8 @@ func main() {
"tn": skate.MapperTitleNormalized,
"ty": skate.MapperTitleNysiis,
"ts": skate.MapperTitleSandcrawler,
- "ru": skate.MapperURLFromRef,
+ "ur": skate.MapperURLFromRef,
+ "ru": skate.MapperIdentURLFromRef,
"cni": skate.MapperContainerName,
"cns": skate.MapperContainerNameSandcrawler,
"rcns": skate.MapperReleaseContainerName,
diff --git a/skate/map.go b/skate/map.go
index 62a347d..1a8feef 100644
--- a/skate/map.go
+++ b/skate/map.go
@@ -222,11 +222,24 @@ func MapperContainerNameSandcrawler(p []byte) (fields [][]byte, err error) {
return fields, nil
}
-// MapperURLFromRef extracts the (work ident, release ident, url, doc).
+// MapperURLFromRef extracts the (url, doc).
+func MapperURLFromRef(p []byte) (fields [][]byte, err error) {
+ var ref Ref
+ if err = json.Unmarshal(p, &ref); err != nil {
+ return nil, err
+ }
+ fields = [][]byte{
+ []byte(ref.Biblio.Url),
+ p,
+ }
+ return fields, nil
+}
+
+// MapperIdentURLFromRef extracts the (work ident, release ident, url, doc).
// Previously: parallel -j 16 --block 100M --pipe "jq -rc '[.work_ident,
// .release_ident, .biblio.url?] | @tsv'" ...
// This implementation seems slightly faster than jq and parallel.
-func MapperURLFromRef(p []byte) (fields [][]byte, err error) {
+func MapperIdentURLFromRef(p []byte) (fields [][]byte, err error) {
var ref Ref
if err = json.Unmarshal(p, &ref); err != nil {
return nil, err