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..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 @@ -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; @@ -48,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; @@ -991,10 +991,24 @@ 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); + 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)); } /**