Merge pull request #349 from lblod/feat/phone-number-format-migration
Feat/phone number format migration
This commit is contained in:
@@ -0,0 +1,202 @@
|
||||
#fix nrs starting with 0032 in Administrative-unit
|
||||
|
||||
DELETE {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?fixedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?convertedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/administrative-unit> {
|
||||
?s <http://schema.org/telephone> ?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 <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?o .
|
||||
}
|
||||
}
|
||||
INSERT {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?convertedTel .
|
||||
}
|
||||
}
|
||||
WHERE {
|
||||
GRAPH <http://mu.semte.ch/graphs/worship-service> {
|
||||
?s <http://schema.org/telephone> ?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) .
|
||||
}
|
||||
;
|
||||
53
config/reasoner/dl2op/main-info/phone_number.n3
Normal file
53
config/reasoner/dl2op/main-info/phone_number.n3
Normal file
@@ -0,0 +1,53 @@
|
||||
PREFIX string: <http://www.w3.org/2000/10/swap/string#>
|
||||
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
|
||||
PREFIX schema: <http://schema.org/>
|
||||
PREFIX : <#>
|
||||
PREFIX adms: <http://www.w3.org/ns/adms#>
|
||||
PREFIX adres: <https://data.vlaanderen.be/ns/adres#>
|
||||
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
|
||||
PREFIX crypto: <http://www.w3.org/2000/10/swap/crypto#>
|
||||
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
|
||||
PREFIX ex: <http://example.org/test#>
|
||||
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||
PREFIX func: <http://www.w3.org/2007/rif-builtin-function#>
|
||||
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
|
||||
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
|
||||
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
||||
PREFIX org: <http://www.w3.org/ns/org#>
|
||||
PREFIX persoon: <https://data.vlaanderen.be/ns/persoon#>
|
||||
PREFIX persoon_loket: <http://data.vlaanderen.be/ns/persoon#>
|
||||
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
|
||||
PREFIX string: <http://www.w3.org/2000/10/swap/string#>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
{
|
||||
?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 .
|
||||
}.
|
||||
53
config/reasoner/dl2op/main/phone_number.n3
Normal file
53
config/reasoner/dl2op/main/phone_number.n3
Normal file
@@ -0,0 +1,53 @@
|
||||
PREFIX string: <http://www.w3.org/2000/10/swap/string#>
|
||||
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
|
||||
PREFIX schema: <http://schema.org/>
|
||||
PREFIX : <#>
|
||||
PREFIX adms: <http://www.w3.org/ns/adms#>
|
||||
PREFIX adres: <https://data.vlaanderen.be/ns/adres#>
|
||||
PREFIX besluit: <http://data.vlaanderen.be/ns/besluit#>
|
||||
PREFIX crypto: <http://www.w3.org/2000/10/swap/crypto#>
|
||||
PREFIX e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
|
||||
PREFIX ex: <http://example.org/test#>
|
||||
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
||||
PREFIX func: <http://www.w3.org/2007/rif-builtin-function#>
|
||||
PREFIX generiek: <https://data.vlaanderen.be/ns/generiek#>
|
||||
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
|
||||
PREFIX mandaat: <http://data.vlaanderen.be/ns/mandaat#>
|
||||
PREFIX mu: <http://mu.semte.ch/vocabularies/core/>
|
||||
PREFIX org: <http://www.w3.org/ns/org#>
|
||||
PREFIX persoon: <https://data.vlaanderen.be/ns/persoon#>
|
||||
PREFIX persoon_loket: <http://data.vlaanderen.be/ns/persoon#>
|
||||
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
|
||||
PREFIX string: <http://www.w3.org/2000/10/swap/string#>
|
||||
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
||||
{
|
||||
?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 .
|
||||
}.
|
||||
@@ -26,6 +26,16 @@
|
||||
?p ?o .
|
||||
}.
|
||||
|
||||
# For functionarissen, the contact point is on the bestuursfunctie and not on the agent in position
|
||||
|
||||
{
|
||||
?s a <http://data.lblod.info/vocabularies/leidinggevenden/Bestuursfunctie> ;
|
||||
<http://schema.org/contactPoint> ?o .
|
||||
} => {
|
||||
?s a <http://data.lblod.info/vocabularies/leidinggevenden/Bestuursfunctie> ;
|
||||
<http://schema.org/contactPoint> ?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 <http://www.w3.org/ns/org#Membership> ;
|
||||
?p ?o .
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user