From d0413165c6259d8c69f04948ceb649eb40910d0b Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sat, 22 May 2021 00:20:48 +0200 Subject: add OpenLibraryMapped --- python/refcat/tasks.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'python') diff --git a/python/refcat/tasks.py b/python/refcat/tasks.py index faf76fd..d17a1f9 100644 --- a/python/refcat/tasks.py +++ b/python/refcat/tasks.py @@ -707,3 +707,30 @@ class OpenLibraryWorks(Refcat): def output(self): return luigi.LocalTarget(path=self.path(ext="json.zst"), format=Zstd) + + +class OpenLibraryMapped(Refcat): + """ + Map OL data with e.g. a title normalizing mapper. + """ + mapper = luigi.Parameter(default="ts", description="mapper short name") + + def requires(self): + return OpenLibraryWorks() + + def run(self): + output = shellout(""" + zstdcat -T0 {input} | + skate-conv -f ol | + skate-map -m {mapper} -skip-on-empty 1 | + LC_ALL=C sort -T {tmpdir} -k1,1 -S25% --parallel 4 | + zstd -T0 -c > {output} + """, + n=self.n, + mapper=self.mapper, + tmpdir=self.tmpdir, + input=self.input().path) + luigi.LocalTarget(output).move(self.output().path) + + def output(self): + return luigi.LocalTarget(path=self.path(ext="tsv.zst"), format=Zstd) -- cgit v1.2.3