diff options
-rw-r--r-- | python/refcat/tasks.py | 27 |
1 files changed, 27 insertions, 0 deletions
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) |