From 39ef07039667b30df659f44162162031ca063baa Mon Sep 17 00:00:00 2001 From: Bob Coret Date: Wed, 20 Nov 2024 19:10:34 +0100 Subject: [PATCH] deduplicate organisatio names fix #43 --- web/includes/search.php | 27 +++++++++++++++++++++++---- web/search.php | 6 ++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/web/includes/search.php b/web/includes/search.php index 6bddd6a..9778e33 100644 --- a/web/includes/search.php +++ b/web/includes/search.php @@ -44,10 +44,20 @@ function getCreators() { $creators=array(); if (isset($sparqlResults)) { foreach ($sparqlResults["results"]["bindings"] as $item) { - $creators[$item["creator"]["value"]]=$item["creator_name"]["value"]; + # not-so-nice work-around to deduplicate organisation names + $index=trim($item["creator_name"]["value"]); + if ($index=="Rijksdienst voor Cultureel Erfgoed") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if ($index=="Rijksdienst voor Cultureel Erfgoed - Kunstcollectie") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if ($index=="Rijksdienst voor het Cultureel Erfgoed (RCE)") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if (!isset($creators[$index])) { + $creators[$index]=$item["creator"]["value"]; + } else { + $creators[$index].="|".$item["creator"]["value"]; + } } } - return $creators; + + return array_flip($creators); } function getPublishers() { @@ -72,10 +82,19 @@ function getPublishers() { $publishers=array(); if (isset($sparqlResults)) { foreach ($sparqlResults["results"]["bindings"] as $item) { - $publishers[$item["publisher"]["value"]]=$item["publisher_name"]["value"]; + # not-so-nice work-around to deduplicate organisation names + $index=trim($item["publisher_name"]["value"]); + if ($index=="Rijksdienst voor Cultureel Erfgoed") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if ($index=="Rijksdienst voor Cultureel Erfgoed - Kunstcollectie") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if ($index=="Rijksdienst voor het Cultureel Erfgoed (RCE)") { $index="Rijksdienst voor het Cultureel Erfgoed";} + if (!isset($publishers[$index])) { + $publishers[$index]=$item["publisher"]["value"]; + } else { + $publishers[$index].="|".$item["publisher"]["value"]; + } } } - return $publishers; + return array_flip($publishers); } function getNewest() { diff --git a/web/search.php b/web/search.php index e80135d..2596375 100644 --- a/web/search.php +++ b/web/search.php @@ -96,10 +96,12 @@ function updateSparql() { OPTIONAL { ?publisher foaf:name ?publisherName } `; if (creator) { - sparqlQuery += " ?dataset dct:creator <" + creator + "> .\n"; + sparqlQuery += " ?dataset dct:creator ?creator .\n"; + sparqlQuery += " VALUES ?publisher {<"+creator.split('|').join("> <")+">}\n"; } if (publisher) { - sparqlQuery += " ?dataset dct:publisher <" + publisher + "> .\n"; + sparqlQuery += " ?dataset dct:publisher ?publisher .\n"; + sparqlQuery += " VALUES ?publisher {<"+publisher.split('|').join("> <")+">}\n"; } if (formats.size > 0) { sparqlQuery += " ?dataset dcat:distribution ?distribution .\n";