diff --git a/config/migrations/2023/202311121615322-update-phone-numbers.sparql b/config/migrations/2023/202311121615322-update-phone-numbers.sparql new file mode 100644 index 0000000..5e56d80 --- /dev/null +++ b/config/migrations/2023/202311121615322-update-phone-numbers.sparql @@ -0,0 +1,202 @@ +#fix nrs starting with 0032 in Administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + +#fix nrs starting with 0032 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + + +#fix nrs starting with 320 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "320")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 4)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; +#fix nrs starting with 320 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0032")) . + BIND(CONCAT("+32", SUBSTR(?removedSpaces, 5)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + +#fix nrs starting with 0 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 2)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . +} +; + + +#fix nrs starting with 03/04 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?fixedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "0")) . + BIND(CONCAT("32", SUBSTR(?removedSpaces, 2)) as ?newTel ) . + FILTER(STRLEN(?newTel) > 9 and STRLEN(?newTel) < 12) . + BIND(CONCAT("+", ?newTel) AS ?fixedTel) . + +} +; + +#convert all nrs starting with 32 in administrative-unit + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?convertedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "32") AND STRLEN(?removedSpaces) > 9 and STRLEN(?removedSpaces) < 12) . + BIND(CONCAT("tel:+", ?removedSpaces) as ?convertedTel) . +} +; + + +#convert all nrs starting with 32 in worship-service + +DELETE { + GRAPH { + ?s ?o . + } +} +INSERT { + GRAPH { + ?s ?convertedTel . + } +} +WHERE { + GRAPH { + ?s ?o . + } + + FILTER(!regex(?o, ".*[a-zA-Z].*", "i")) . + BIND(REPLACE(STR(?o),"[. -/();:=+]","") AS ?removedSpaces) . + FILTER(STRSTARTS(?removedSpaces, "32") AND STRLEN(?removedSpaces) > 9 and STRLEN(?removedSpaces) < 12) . + BIND(CONCAT("tel:+", ?removedSpaces) as ?convertedTel) . +} +; \ No newline at end of file diff --git a/config/reasoner/dl2op/main-info/phone_number.n3 b/config/reasoner/dl2op/main-info/phone_number.n3 new file mode 100644 index 0000000..f83f5ad --- /dev/null +++ b/config/reasoner/dl2op/main-info/phone_number.n3 @@ -0,0 +1,53 @@ +PREFIX string: +PREFIX e: +PREFIX schema: +PREFIX : <#> +PREFIX adms: +PREFIX adres: +PREFIX besluit: +PREFIX crypto: +PREFIX e: +PREFIX ex: +PREFIX foaf: +PREFIX func: +PREFIX generiek: +PREFIX log: +PREFIX mandaat: +PREFIX mu: +PREFIX org: +PREFIX persoon: +PREFIX persoon_loket: +PREFIX skos: +PREFIX string: +PREFIX xsd: +{ + ?s schema:telephone ?number. + + # number not matches regex + + ?number string:notMatches """[a-zA-Z]""". + + # Remove all non digits + ( ?number """[^+\\d]""" "" ) string:replace ?scrape_result. + + # Replace leading 00 with + + ( ?scrape_result """^00""" "+") string:replace ?replaced_zero_zero. + + ( ?replaced_zero_zero """^0""" "+32") string:replace ?default_be. + + ( ?default_be """\\+320""" "+32" ) string:replace ?result. + + # ?result string:matches """^+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""". + ?result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""". + + ( "tel:" ?result ) string:concatenation ?parsed_result . + + { + ?s schema:telephone ?number. + } e:becomes { + ?s schema:telephone ?parsed_result . + }. + +} => { + ?s schema:telephone ?parsed_result . +}. diff --git a/config/reasoner/dl2op/main/phone_number.n3 b/config/reasoner/dl2op/main/phone_number.n3 new file mode 100644 index 0000000..f83f5ad --- /dev/null +++ b/config/reasoner/dl2op/main/phone_number.n3 @@ -0,0 +1,53 @@ +PREFIX string: +PREFIX e: +PREFIX schema: +PREFIX : <#> +PREFIX adms: +PREFIX adres: +PREFIX besluit: +PREFIX crypto: +PREFIX e: +PREFIX ex: +PREFIX foaf: +PREFIX func: +PREFIX generiek: +PREFIX log: +PREFIX mandaat: +PREFIX mu: +PREFIX org: +PREFIX persoon: +PREFIX persoon_loket: +PREFIX skos: +PREFIX string: +PREFIX xsd: +{ + ?s schema:telephone ?number. + + # number not matches regex + + ?number string:notMatches """[a-zA-Z]""". + + # Remove all non digits + ( ?number """[^+\\d]""" "" ) string:replace ?scrape_result. + + # Replace leading 00 with + + ( ?scrape_result """^00""" "+") string:replace ?replaced_zero_zero. + + ( ?replaced_zero_zero """^0""" "+32") string:replace ?default_be. + + ( ?default_be """\\+320""" "+32" ) string:replace ?result. + + # ?result string:matches """^+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""". + ?result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""". + + ( "tel:" ?result ) string:concatenation ?parsed_result . + + { + ?s schema:telephone ?number. + } e:becomes { + ?s schema:telephone ?parsed_result . + }. + +} => { + ?s schema:telephone ?parsed_result . +}. diff --git a/config/reasoner/dl2op/main/query.n3q b/config/reasoner/dl2op/main/query.n3q index b72ce01..1db4e37 100644 --- a/config/reasoner/dl2op/main/query.n3q +++ b/config/reasoner/dl2op/main/query.n3q @@ -26,6 +26,16 @@ ?p ?o . }. +# For functionarissen, the contact point is on the bestuursfunctie and not on the agent in position + +{ + ?s a ; + ?o . + } => { + ?s a ; + ?o . +}. + # Functionarissen should be linked to an igs, agb, apb, gemeente, district, provincie or ocmw only (FOR NOW) { @@ -225,8 +235,6 @@ ?p ?o . }. - - { ?s a ; ?p ?o . diff --git a/docker-compose.yml b/docker-compose.yml index e6b5e9a..3b4de11 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -263,7 +263,7 @@ services: restart: always logging: *default-logging reasoner: - image: eyereasoner/reasoning-service:increased-stack-limit + image: eyereasoner/reasoning-service:1.0.4 volumes: - ./config/reasoner:/config labels: