From 1cdc2e9c46cf445fedbd1abd2a2e850db5de48dc Mon Sep 17 00:00:00 2001 From: Nordine Bittich <3816305+nbittich@users.noreply.github.com> Date: Thu, 16 Jun 2022 08:27:35 +0200 Subject: [PATCH] normalize spaces (#157) --- .../202206131O4623-normalize-space.sparql | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 config/migrations/2022/202206131O4623-normalize-space.sparql diff --git a/config/migrations/2022/202206131O4623-normalize-space.sparql b/config/migrations/2022/202206131O4623-normalize-space.sparql new file mode 100644 index 0000000..ca1b34d --- /dev/null +++ b/config/migrations/2022/202206131O4623-normalize-space.sparql @@ -0,0 +1,20 @@ +DELETE { + graph { + ?s ?p ?o. + } + +} +INSERT { + graph { + ?s ?p ?normalize. + } +} +WHERE { + graph { + ?s ?p ?o. + BIND(replace(?o, "\\s+|\\t", " ") AS ?single_space) + BIND(replace(?single_space, "^(\\s+)|(\\s+)$|(\\t)$|(\\t)", "") AS ?normalize) + + FILTER ( isLiteral(?o) && ( regex(?o, "\\s+|\\t") || regex(?o, "^(\\s+)|(\\s+)$|(\\t)$|(\\t)") ) ) + } +} \ No newline at end of file