From b9263514b2c6251633708795357ac54dc38753c7 Mon Sep 17 00:00:00 2001 From: Elias Papanikitas Date: Thu, 7 Dec 2023 13:09:31 +0100 Subject: [PATCH 1/2] updated to handle more number correctly --- .../reasoner/dl2op/main-info/phone_number.n3 | 37 ++++++------------- config/reasoner/dl2op/main/phone_number.n3 | 37 ++++++------------- 2 files changed, 22 insertions(+), 52 deletions(-) diff --git a/config/reasoner/dl2op/main-info/phone_number.n3 b/config/reasoner/dl2op/main-info/phone_number.n3 index f83f5ad..4a2d2f2 100644 --- a/config/reasoner/dl2op/main-info/phone_number.n3 +++ b/config/reasoner/dl2op/main-info/phone_number.n3 @@ -2,46 +2,31 @@ 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. + ( ?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: } => { ?s schema:telephone ?parsed_result . -}. +}. \ No newline at end of file diff --git a/config/reasoner/dl2op/main/phone_number.n3 b/config/reasoner/dl2op/main/phone_number.n3 index f83f5ad..4a2d2f2 100644 --- a/config/reasoner/dl2op/main/phone_number.n3 +++ b/config/reasoner/dl2op/main/phone_number.n3 @@ -2,46 +2,31 @@ 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. + ( ?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: } => { ?s schema:telephone ?parsed_result . -}. +}. \ No newline at end of file From fbde10887b44ffaeaafd9dcf405aabbc17f2b7f2 Mon Sep 17 00:00:00 2001 From: Elias Papanikitas Date: Thu, 7 Dec 2023 13:35:47 +0100 Subject: [PATCH 2/2] cleaned up code --- config/reasoner/dl2op/main-info/phone_number.n3 | 6 ------ config/reasoner/dl2op/main/phone_number.n3 | 6 ------ 2 files changed, 12 deletions(-) diff --git a/config/reasoner/dl2op/main-info/phone_number.n3 b/config/reasoner/dl2op/main-info/phone_number.n3 index 4a2d2f2..da5ce99 100644 --- a/config/reasoner/dl2op/main-info/phone_number.n3 +++ b/config/reasoner/dl2op/main-info/phone_number.n3 @@ -3,14 +3,8 @@ PREFIX e: PREFIX schema: PREFIX : <#> { - - ?s schema:telephone ?number. - # number not matches regex - ?number string:notMatches """[a-zA-Z]""". - - # Remove all non digits ( ?number ("""[^+\\d]""") ("") ) string:replaceAll ?scrape_result. diff --git a/config/reasoner/dl2op/main/phone_number.n3 b/config/reasoner/dl2op/main/phone_number.n3 index 4a2d2f2..da5ce99 100644 --- a/config/reasoner/dl2op/main/phone_number.n3 +++ b/config/reasoner/dl2op/main/phone_number.n3 @@ -3,14 +3,8 @@ PREFIX e: PREFIX schema: PREFIX : <#> { - - ?s schema:telephone ?number. - # number not matches regex - ?number string:notMatches """[a-zA-Z]""". - - # Remove all non digits ( ?number ("""[^+\\d]""") ("") ) string:replaceAll ?scrape_result.