updated to handle more number correctly

This commit is contained in:
Elias Papanikitas
2023-12-07 13:09:31 +01:00
parent 7bcc9f09ee
commit b9263514b2
2 changed files with 22 additions and 52 deletions

View File

@@ -2,46 +2,31 @@ 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.
( ?number ("""[^+\\d]""") ("") ) string:replaceAll ?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.
( ?default_be """\\+320""" "+32" ) string:replace ?replace_320.
# ?result string:matches """^+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
?result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
( ?replace_320 """^320""" "+32" ) string:replace ?final_result.
?final_result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
( "tel:" ?final_result ) string:concatenation ?parsed_result .
( "tel:" ?result ) string:concatenation ?parsed_result .
{
?s schema:telephone ?number.
} e:becomes {
@@ -50,4 +35,4 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
} => {
?s schema:telephone ?parsed_result .
}.
}.

View File

@@ -2,46 +2,31 @@ 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.
( ?number ("""[^+\\d]""") ("") ) string:replaceAll ?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.
( ?default_be """\\+320""" "+32" ) string:replace ?replace_320.
# ?result string:matches """^+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
?result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
( ?replace_320 """^320""" "+32" ) string:replace ?final_result.
?final_result string:matches """^\\+((32\\d{8})|(324\\d{8})|((?!32)\\d+))$""".
( "tel:" ?final_result ) string:concatenation ?parsed_result .
( "tel:" ?result ) string:concatenation ?parsed_result .
{
?s schema:telephone ?number.
} e:becomes {
@@ -50,4 +35,4 @@ PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
} => {
?s schema:telephone ?parsed_result .
}.
}.