Skip to content

Commit

Permalink
Move ITs from elk-snomed-owl to elk-snomed, using new parse/transform.
Browse files Browse the repository at this point in the history
  • Loading branch information
emays committed Nov 16, 2024
1 parent 0198725 commit f6fb866
Show file tree
Hide file tree
Showing 21 changed files with 126 additions and 263 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import dev.ikm.elk.snomed.model.Concept;
import dev.ikm.elk.snomed.model.Definition;
import dev.ikm.elk.snomed.model.RoleGroup;
import dev.ikm.elk.snomed.owl.SnomedOwlOntology;

public class NecessaryNormalFormTest {

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
* ELK Integration with SNOMED
* %%
* Copyright (C) 2023 Integrated Knowledge Management
* Copyright (C) 2023 - 2024 Integrated Knowledge Management
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,61 +20,51 @@
* #L%
*/

import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.HashSet;

import org.junit.jupiter.api.Test;
import org.semanticweb.owlapi.model.OWLAxiom;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import dev.ikm.elk.snomed.ConceptComparer;
import dev.ikm.elk.snomed.NecessaryNormalFormBuilder;
import dev.ikm.elk.snomed.SnomedConcreteRoles;
import dev.ikm.elk.snomed.SnomedOntology;
import dev.ikm.elk.snomed.SnomedOntologyReasoner;
import dev.ikm.elk.snomed.SnomedRoles;
import dev.ikm.elk.snomed.model.Concept;
import dev.ikm.elk.snomed.owlel.OwlElOntology;

public abstract class SnomedNecessaryNormalFormTestBase extends SnomedTestBase {

private static final Logger LOG = LoggerFactory.getLogger(SnomedNecessaryNormalFormTestBase.class);

public static void checkPriors(SnomedOntologyReasoner ontology, NecessaryNormalFormBuilder nnf) {
HashSet<Long> priors = new HashSet<>();
for (Concept con : nnf.getConcepts()) {
for (Long sup : ontology.getSuperConcepts(con.getId())) {
assertTrue(priors.contains(sup));
}
priors.add(con.getId());
}
}

@Test
public void checkPriors() throws Exception {
SnomedOwlOntology ontology = SnomedOwlOntology.createOntology();
ontology.loadOntology(axioms_file);
ontology.classify();
SnomedOntology snomedOntology = new OwlTransformer().transform(ontology);
OwlElOntology ontology = new OwlElOntology();
ontology.load(axioms_file);
// ontology.classify();
SnomedOntology snomedOntology = new OwlElTransformer().transform(ontology);
SnomedOntologyReasoner snomedOntologyReasoner = SnomedOntologyReasoner.create(snomedOntology);
snomedOntologyReasoner.flush();
NecessaryNormalFormBuilder nnfb = NecessaryNormalFormBuilder.create(snomedOntology,
snomedOntologyReasoner.getSuperConcepts(), snomedOntologyReasoner.getSuperRoleTypes(false));
NecessaryNormalFormTest.checkPriors(ontology, nnfb);
checkPriors(snomedOntologyReasoner, nnfb);
}

public NecessaryNormalFormBuilder generate() throws Exception {
SnomedOwlOntology ontology = SnomedOwlOntology.createOntology();
ontology.loadOntology(axioms_file);
OwlElOntology ontology = new OwlElOntology();
ontology.load(axioms_file);

LOG.info("Load complete");
//
for (OWLAxiom ax : ontology.getOntology().getAxioms()) {
switch (ax.getAxiomType().getName()) {
case "SubClassOf" -> {
}
case "EquivalentClasses" -> {
}
case "SubObjectPropertyOf" -> {
}
case "SubPropertyChainOf" -> {
}
case "TransitiveObjectProperty" -> {
}
case "ReflexiveObjectProperty" -> {
}
case "SubDataPropertyOf" -> {
}
default -> throw new UnsupportedOperationException("Unexpected: " + ax + " " + ax.getAxiomType());
}
}
//
SnomedOntology snomedOntology = new OwlTransformer().transform(ontology);
SnomedOntology snomedOntology = new OwlElTransformer().transform(ontology);
SnomedOntologyReasoner snomedOntologyReasoner = SnomedOntologyReasoner.create(snomedOntology);
snomedOntologyReasoner.flush();
NecessaryNormalFormBuilder nnfb = NecessaryNormalFormBuilder.create(snomedOntology,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.ikm.elk.snomed.owl;
package dev.ikm.elk.snomed;

/*-
* #%L
Expand Down
Loading

0 comments on commit f6fb866

Please sign in to comment.