diff --git a/CHANGELOG.md b/CHANGELOG.md index 40198a9ed..c7792b029 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Added option to input template strings from external file [#1152] +### Changed +- Updated `duplicate_exact_syonym` [`report`] query to be case-insensitive and ignore synoyms annotated as abbreviation or acronym synonym types [#1179] + ### Fixed - '--annotate-with-source true' does not work with extract --method subset [#1160] - Fix how Template adds entities to the QuotedEntityChecker [#1104] @@ -388,6 +391,7 @@ First official release of ROBOT! [`validate`]: http://robot.obolibrary.org/validate ; [#1181]: https://github.com/ontodev/robot/pull/1181 +[#1179]: https://github.com/ontodev/robot/pull/1179 [#1171]: https://github.com/ontodev/robot/pull/1171 [#1168]: https://github.com/ontodev/robot/pull/1168 [#1160]: https://github.com/ontodev/robot/pull/1160 diff --git a/docs/report_queries/duplicate_exact_synonym.md b/docs/report_queries/duplicate_exact_synonym.md index d30bc53fa..86263e070 100644 --- a/docs/report_queries/duplicate_exact_synonym.md +++ b/docs/report_queries/duplicate_exact_synonym.md @@ -1,8 +1,8 @@ # Duplicate Exact Synonym -**Problem:** Two entities share an exact synonym. This causes ambiguity. Excludes deprecated entities. +**Problem:** Two entities share an exact synonym (case-insensitive). This causes ambiguity. Excludes deprecated entities and synonyms annotated as abbreviation or acronym. -**Solution:** Avoid ambiguity by assigning unique exact synonyms or changing the exact synonym to a different annotation (e.g. broad synonym). +**Solution:** Avoid ambiguity by assigning unique exact synonyms, changing the exact synonym to a different annotation (e.g. broad synonym), or annotating it as an abbreviation or acronym. ```sparql PREFIX obo: @@ -10,18 +10,31 @@ PREFIX oboInOwl: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?entity ?property ?value WHERE { - VALUES ?property { - obo:IAO_0000118 - oboInOwl:hasExactSynonym +SELECT DISTINCT ?entity ?property ?value +WHERE { + { + SELECT DISTINCT ?syn_std ?property (COUNT(DISTINCT ?entity) AS ?cnt) + WHERE { + VALUES ?property { obo:IAO_0000118 oboInOwl:hasExactSynonym } + ?entity ?property ?syn . + OPTIONAL { + VALUES ?syn_type { obo:OMO_0003000 obo:OMO_0003012 } + ?exclude a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty ?property ; + owl:annotatedTarget ?syn ; + oboInOwl:hasSynonymType ?syn_type . + } + + BIND(UCASE(?syn) AS ?syn_std) + FILTER (!isBlank(?entity) && !BOUND(?exclude)) + FILTER NOT EXISTS { ?entity owl:deprecated true } + } GROUP BY ?syn_std ?property HAVING (?cnt > 1) } - ?entity ?property ?value. - ?entity2 ?property ?value . - FILTER NOT EXISTS { ?entity owl:deprecated true } - FILTER NOT EXISTS { ?entity2 owl:deprecated true } - FILTER (?entity != ?entity2) + ?entity ?property ?value . FILTER (!isBlank(?entity)) - FILTER (!isBlank(?entity2)) + FILTER NOT EXISTS { ?entity owl:deprecated true } + FILTER (UCASE(?value) = ?syn_std) } ORDER BY DESC(UCASE(str(?value))) -``` +``` \ No newline at end of file diff --git a/robot-core/src/main/resources/report_queries/duplicate_exact_synonym.rq b/robot-core/src/main/resources/report_queries/duplicate_exact_synonym.rq index 6f1f438bb..319725b71 100644 --- a/robot-core/src/main/resources/report_queries/duplicate_exact_synonym.rq +++ b/robot-core/src/main/resources/report_queries/duplicate_exact_synonym.rq @@ -1,25 +1,38 @@ # # Duplicate Exact Synonym # -# **Problem:** Two entities share an exact synonym. This causes ambiguity. Excludes deprecated entities. +# **Problem:** Two entities share an exact synonym (case-insensitive). This causes ambiguity. Excludes deprecated entities and synonyms annotated as abbreviation or acronym. # -# **Solution:** Avoid ambiguity by assigning unique exact synonyms or changing the exact synonym to a different annotation (e.g. broad synonym). +# **Solution:** Avoid ambiguity by assigning unique exact synonyms, changing the exact synonym to a different annotation (e.g. broad synonym), or annotating it as an abbreviation or acronym. PREFIX obo: PREFIX oboInOwl: PREFIX owl: PREFIX rdfs: -SELECT DISTINCT ?entity ?property ?value WHERE { - VALUES ?property { - obo:IAO_0000118 - oboInOwl:hasExactSynonym +SELECT DISTINCT ?entity ?property ?value +WHERE { + { + SELECT DISTINCT ?syn_std ?property (COUNT(DISTINCT ?entity) AS ?cnt) + WHERE { + VALUES ?property { obo:IAO_0000118 oboInOwl:hasExactSynonym } + ?entity ?property ?syn . + OPTIONAL { + VALUES ?syn_type { obo:OMO_0003000 obo:OMO_0003012 } + ?exclude a owl:Axiom ; + owl:annotatedSource ?entity ; + owl:annotatedProperty ?property ; + owl:annotatedTarget ?syn ; + oboInOwl:hasSynonymType ?syn_type . + } + + BIND(UCASE(?syn) AS ?syn_std) + FILTER (!isBlank(?entity) && !BOUND(?exclude)) + FILTER NOT EXISTS { ?entity owl:deprecated true } + } GROUP BY ?syn_std ?property HAVING (?cnt > 1) } - ?entity ?property ?value. - ?entity2 ?property ?value . - FILTER NOT EXISTS { ?entity owl:deprecated true } - FILTER NOT EXISTS { ?entity2 owl:deprecated true } - FILTER (?entity != ?entity2) + ?entity ?property ?value . FILTER (!isBlank(?entity)) - FILTER (!isBlank(?entity2)) + FILTER NOT EXISTS { ?entity owl:deprecated true } + FILTER (UCASE(?value) = ?syn_std) } -ORDER BY DESC(UCASE(str(?value))) +ORDER BY DESC(UCASE(str(?value))) \ No newline at end of file