Files
app-organization-portal/config/reasoner/dl2op/main/phone_number.n3
Elias Papanikitas fbde10887b cleaned up code
2023-12-07 13:35:47 +01:00

32 lines
904 B
Plaintext

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 : <#>
{
?s schema:telephone ?number.
# Remove all non digits
( ?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 ?replace_320.
( ?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 .
{
?s schema:telephone ?number.
} e:becomes {
?s schema:telephone ?parsed_result .
}.
} => {
?s schema:telephone ?parsed_result .
}.