From b851fad3d01627a43f6c265ddc82ed00a20b8af1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olov=20Ylinenp=C3=A4=C3=A4?= Date: Sat, 23 Oct 2021 01:12:46 +0200 Subject: [PATCH] Fix publication place script --- .../analysis/lxl-2483-publication-place.groovy | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/whelktool/scripts/analysis/lxl-2483-publication-place.groovy b/whelktool/scripts/analysis/lxl-2483-publication-place.groovy index dbeda0104f..0a235479b6 100644 --- a/whelktool/scripts/analysis/lxl-2483-publication-place.groovy +++ b/whelktool/scripts/analysis/lxl-2483-publication-place.groovy @@ -1,17 +1,29 @@ import whelk.Document +errors = getReportWriter("errors.txt") + prod = ['publication', 'production', 'manufacture'] selectByCollection('bib') { doc -> + try { + process(doc) + } + catch (Exception e) { + def m = "${doc.doc.shortId} $e" + println(m) + errors.println(m) + } +} + +void process(doc) { prod.each { p -> getPathSafe(doc.graph, [1, p], []).each { - def place = asList(getPathSafe(it, ['place', 'label'])).flatten() + def place = asList(getPathSafe(it, ['place', 'label'])).flatten().join(' | ') if (place) { incrementStats(p, place) } } } - } Object getPathSafe(item, path, defaultTo = null) {