From 6e7041b6ea9559eff31ce2eba467bf213b65341b Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Fri, 21 Jun 2024 20:27:04 +0300 Subject: [PATCH 1/2] Attempt 1: replacing DLExpressivity by DLExpressivityChecker This is try to sort out the problem that the previous solution shows gibberish expressivity levels: "expressivity": "RRESTRCUCINTUNIVRESTREROIF(D)". But it does not work.. --- .../obolibrary/robot/metrics/OntologyMetrics.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java b/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java index f9d04e673..fc37cee91 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java +++ b/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java @@ -8,7 +8,6 @@ import org.obolibrary.robot.providers.CURIEShortFormProvider; import org.semanticweb.owlapi.metrics.AbstractOWLMetric; import org.semanticweb.owlapi.metrics.AverageAssertedNamedSuperclassCount; -import org.semanticweb.owlapi.metrics.DLExpressivity; import org.semanticweb.owlapi.metrics.GCICount; import org.semanticweb.owlapi.metrics.HiddenGCICount; import org.semanticweb.owlapi.metrics.MaximumNumberOfNamedSuperclasses; @@ -991,10 +990,15 @@ private String getOntologyVersionId() { } private String getExpressivity(boolean included) { - DLExpressivity dl = new DLExpressivity(getOntology()); - dl.setImportsClosureUsed(included); - dl.setOntology(getOntology()); - return dl.getValue(); + Set onts = new HashSet<>(); + if (included) { + onts.addAll(getOntology().getImportsClosure()); + } else { + onts.add(getOntology()); + } + DLExpressivityChecker checker = new DLExpressivityChecker(onts); + System.err.println(checker.getDescriptionLogicName()); + return checker.getDescriptionLogicName(); } // this is highly unpleasant and I wish we had a NoSQL DB or even just a From 4c948fd377416a99061efa3ccf44f4ac8bff3a23 Mon Sep 17 00:00:00 2001 From: Nico Matentzoglu Date: Sat, 22 Jun 2024 09:55:22 +0300 Subject: [PATCH 2/2] Attempt 2: Using sorted expressibleInLanguages() for expressivity calculation @ckindermann has suggested this approach. I relies on the fact that expressibleInLanguages() give the set of all languages, and the sorting sorts by whether one is contained in another. --- .../obolibrary/robot/metrics/OntologyMetrics.java | 14 ++++++++++++-- .../org/obolibrary/robot/MeasureOperationTest.java | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java b/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java index fc37cee91..4624193c9 100644 --- a/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java +++ b/robot-core/src/main/java/org/obolibrary/robot/metrics/OntologyMetrics.java @@ -47,6 +47,7 @@ import org.semanticweb.owlapi.reasoner.OWLReasoner; import org.semanticweb.owlapi.util.Construct; import org.semanticweb.owlapi.util.DLExpressivityChecker; +import org.semanticweb.owlapi.util.Languages; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import uk.ac.manchester.cs.owl.owlapi.OWLObjectOneOfImpl; @@ -997,8 +998,17 @@ private String getExpressivity(boolean included) { onts.add(getOntology()); } DLExpressivityChecker checker = new DLExpressivityChecker(onts); - System.err.println(checker.getDescriptionLogicName()); - return checker.getDescriptionLogicName(); + Collection languages = checker.expressibleInLanguages(); + + if (languages == null || languages.isEmpty()) { + LOGGER.warn("No language found for this ontology.. "); + } else { + Languages[] array = languages.toArray(new Languages[languages.size()]); + Arrays.sort(array); + return array[0].toString(); + } + + return ""; } // this is highly unpleasant and I wish we had a NoSQL DB or even just a diff --git a/robot-core/src/test/java/org/obolibrary/robot/MeasureOperationTest.java b/robot-core/src/test/java/org/obolibrary/robot/MeasureOperationTest.java index f7847c384..d5e7b2e96 100644 --- a/robot-core/src/test/java/org/obolibrary/robot/MeasureOperationTest.java +++ b/robot-core/src/test/java/org/obolibrary/robot/MeasureOperationTest.java @@ -47,7 +47,7 @@ public void testExtendedMetrics() throws IOException { MeasureResult result = MeasureOperation.getMetrics( ontology, "extended", new CURIEShortFormProvider(new IOHelper().getPrefixes())); - assertEquals("RRESTRUCINTE+I(D)", result.getSimpleMetricValue(MetricsLabels.EXPRESSIVITY)); + assertEquals("SID", result.getSimpleMetricValue(MetricsLabels.EXPRESSIVITY)); } /**