diff options
author | Martin Czygan <martin.czygan@gmail.com> | 2021-04-29 15:28:38 +0200 |
---|---|---|
committer | Martin Czygan <martin.czygan@gmail.com> | 2021-04-29 15:28:38 +0200 |
commit | 5e7543c3f4612dacd7f1d4e04c75cd48ecb67b0c (patch) | |
tree | 699f080cb5b8b8d36b2e1eccce7171a70b75651f /skate | |
parent | d03d398cd703ef399254d3ea8e088c59693ef110 (diff) | |
download | refcat-5e7543c3f4612dacd7f1d4e04c75cd48ecb67b0c.tar.gz refcat-5e7543c3f4612dacd7f1d4e04c75cd48ecb67b0c.zip |
no default prefix
Diffstat (limited to 'skate')
-rw-r--r-- | skate/cmd/skate-map/main.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/skate/cmd/skate-map/main.go b/skate/cmd/skate-map/main.go index 259e1aa..ee02875 100644 --- a/skate/cmd/skate-map/main.go +++ b/skate/cmd/skate-map/main.go @@ -49,6 +49,7 @@ var ( numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers") batchSize = flag.Int("b", 50000, "batch size") verbose = flag.Bool("verbose", false, "show progress") + keyPrefix = flag.String("p", "", "a key prefix to use") extraValue = flag.String("x", "", "extra value to pass to configurable mappers") ) @@ -60,17 +61,20 @@ func main() { // [ ] maybe wrap jq and parallel for arbitrary nested keys availableMappers := map[string]skate.Mapper{ "id": skate.Identity, - "ff": skate.WithPrefix(skate.CreateFixedMapper(*extraValue), "ff"), - "ti": skate.WithPrefix(skate.MapperTitle, "ti"), - "tn": skate.WithPrefix(skate.MapperTitleNormalized, "tn"), - "ty": skate.WithPrefix(skate.MapperTitleNysiis, "ty"), - "ts": skate.WithPrefix(skate.MapperTitleSandcrawler, "ts"), + "ff": skate.CreateFixedMapper(*extraValue), + "ti": skate.MapperTitle, + "tn": skate.MapperTitleNormalized, + "ty": skate.MapperTitleNysiis, + "ts": skate.MapperTitleSandcrawler, } switch { case *mapperName != "": if f, ok := availableMappers[*mapperName]; !ok { log.Fatalf("unknown mapper name: %v", *mapperName) } else { + if *keyPrefix != "" { + f = skate.WithPrefix(f, *keyPrefix) + } pp := parallel.NewProcessor(os.Stdin, os.Stdout, f.AsTSV) pp.NumWorkers = *numWorkers pp.BatchSize = *batchSize |