aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMartin Czygan <martin.czygan@gmail.com>2021-05-22 00:20:48 +0200
committerMartin Czygan <martin.czygan@gmail.com>2021-05-22 00:20:48 +0200
commitd0413165c6259d8c69f04948ceb649eb40910d0b (patch)
tree8a5ef4d8160de36d596c4913b00d76baa8411ebe /python
parent92c2eb36e91a6bf3d6114315fb91494959a49c62 (diff)
downloadrefcat-d0413165c6259d8c69f04948ceb649eb40910d0b.tar.gz
refcat-d0413165c6259d8c69f04948ceb649eb40910d0b.zip
add OpenLibraryMapped
Diffstat (limited to 'python')
-rw-r--r--python/refcat/tasks.py27
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)