public Set<OWLAxiom> getAxioms(Set<OWLOntology> sourceOntologies) { Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); for (OWLOntology ont: sourceOntologies){ axioms.addAll(ont.getAxioms()); } for (OWLOntology ont : sourceOntologies){ OWLProfileReport report = profile.checkOntology(ont); for (OWLProfileViolation disConstr : report.getViolations()){ axioms.remove(disConstr.getAxiom()); } } return axioms; }
public Set<OWLAxiom> getAxioms(Set<OWLOntology> sourceOntologies) { Set<OWLAxiom> axioms = new HashSet<>(); for (OWLOntology ont: sourceOntologies){ axioms.addAll(ont.getAxioms()); } for (OWLOntology ont : sourceOntologies){ OWLProfileReport report = profile.checkOntology(ont); for (OWLProfileViolation disConstr : report.getViolations()){ axioms.remove(disConstr.getAxiom()); } } return axioms; }
public Set<OWLAxiom> getAxioms(Set<OWLOntology> sourceOntologies) { Set<OWLAxiom> axioms = new HashSet<>(); for (OWLOntology ont: sourceOntologies){ axioms.addAll(ont.getAxioms()); } for (OWLOntology ont : sourceOntologies){ OWLProfileReport report = profile.checkOntology(ont); for (OWLProfileViolation disConstr : report.getViolations()){ axioms.remove(disConstr.getAxiom()); } } return axioms; }
public Set<OWLAxiom> getAxioms(Set<OWLOntology> sourceOntologies) { Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); for (OWLOntology ont: sourceOntologies){ axioms.addAll(ont.getAxioms()); } for (OWLOntology ont : sourceOntologies){ OWLProfileReport report = profile.checkOntology(ont); for (OWLProfileViolation disConstr : report.getViolations()){ axioms.remove(disConstr.getAxiom()); } } return axioms; }
private String getOWL2DLProfileViolations(final OWLOntology ontology) { final OWL2DLProfile owl2Profile = new OWL2DLProfile(); final OWLProfileReport profileReport = owl2Profile.checkOntology(ontology); if (profileReport.isInProfile()) return "No OWL 2 DL violations found for ontology " + ontology.getOntologyID().toString(); final StringBuffer result = new StringBuffer(); result.append("\n=========================================================\n"); result.append("OWL 2 DL violations found for ontology ").append(ontology.getOntologyID().toString()).append(":\n"); for (final OWLProfileViolation violation : profileReport.getViolations()) { result.append(violation.toString()); result.append("\n"); } return result.toString(); }
/** * Check OWL2DL profile. * * @param directOntology the direct ontology * @throws Exception the exception */ public static void checkOWL2DLProfile(OWLOntology directOntology) throws Exception { // // Compliance testing - OWL 2 DL // OWL2DLProfile profile = new OWL2DLProfile(); OWLProfileReport report = profile.checkOntology(directOntology); if (!report.isInProfile()) { boolean flag = false; for (OWLProfileViolation violation : report.getViolations()) { // Allow violation: Use of undeclared annotation property if (violation.toString().indexOf( "Use of undeclared annotation property") == -1) { flag = true; break; } } if (flag) { throw new Exception("OWL is not in expected profile OWL DL 2 - " + report); } } }
for (OWLProfileViolation violation : report.getViolations()) {
@Override public List<OWLOntologyChange> applyChanges(OWLOntology o) { T object = buildObject(); if (!(object instanceof OWLAxiom)) { return Collections.emptyList(); } // create and apply the new change AddAxiom change = new AddAxiom(o, (OWLAxiom) object); o.applyChange(change); // check conformity to the profile OWLProfileReport report = Profiles.OWL2_DL.checkOntology(o); // collect all changes to fix the ontology List<OWLOntologyChange> changes = asList( report.getViolations().stream().flatMap(v -> v.repair().stream())); // fix the ontology o.getOWLOntologyManager().applyChanges(changes); // return all applied changes for reference changes.add(change); return changes; } }
public OWLProfileReport checkOntology(OWLOntology ontology) { this.ont = ontology; OWL2DLProfile profile = new OWL2DLProfile(); OWLProfileReport report = profile.checkOntology(ontology); Set<OWLProfileViolation> violations = new HashSet<OWLProfileViolation>(); violations.addAll(report.getViolations()); OWLOntologyWalker ontologyWalker = new OWLOntologyWalker(ontology.getImportsClosure()); OWL2ELProfileObjectVisitor visitor = new OWL2ELProfileObjectVisitor(ontologyWalker, ontology.getOWLOntologyManager()); ontologyWalker.walkStructure(visitor); violations.addAll(visitor.getProfileViolations()); return new OWLProfileReport(this, violations); }
@Override public List<OWLOntologyChange> applyChanges(OWLOntology o) { T object = buildObject(); if (!(object instanceof OWLAxiom)) { return Collections.emptyList(); } // create and apply the new change AddAxiom change = new AddAxiom(o, (OWLAxiom) object); o.applyChange(change); // check conformity to the profile OWLProfileReport report = Profiles.OWL2_DL.checkOntology(o); // collect all changes to fix the ontology List<OWLOntologyChange> changes = asList( report.getViolations().stream().flatMap(v -> v.repair().stream())); // fix the ontology o.getOWLOntologyManager().applyChanges(changes); // return all applied changes for reference changes.add(change); return changes; } }
@Override public List<OWLOntologyChange> applyChanges(OWLOntology o) { T object = buildObject(); if (!(object instanceof OWLAxiom)) { return Collections.emptyList(); } // create and apply the new change AddAxiom change = new AddAxiom(o, (OWLAxiom) object); o.applyChange(change); // check conformity to the profile OWLProfileReport report = Profiles.OWL2_DL.checkOntology(o); // collect all changes to fix the ontology List<OWLOntologyChange> changes = asList(report.getViolations().stream().flatMap(v -> v.repair().stream())); // fix the ontology o.getOWLOntologyManager().applyChanges(changes); // return all applied changes for reference changes.add(change); return changes; } }
@Override public List<OWLOntologyChange> applyChanges(OWLOntology o) { T object = buildObject(); if (!(object instanceof OWLAxiom)) { return Collections.emptyList(); } // create and apply the new change AddAxiom change = new AddAxiom(o, (OWLAxiom) object); o.applyChange(change); // check conformity to the profile OWLProfileReport report = Profiles.OWL2_DL.checkOntology(o); // collect all changes to fix the ontology List<OWLOntologyChange> changes = asList( report.getViolations().stream().flatMap(v -> v.repair().stream())); // fix the ontology o.getOWLOntologyManager().applyChanges(changes); // return all applied changes for reference changes.add(change); return changes; } }
/** * Checks an ontology and its import closure to see if it is within * this profile. * @param ontology The ontology to be checked. * @return An <code>OWLProfileReport</code> that describes whether or not the * ontology is within this profile. */ public OWLProfileReport checkOntology(OWLOntology ontology) { OWL2DLProfile profile = new OWL2DLProfile(); OWLProfileReport report = profile.checkOntology(ontology); Set<OWLProfileViolation> violations = new HashSet<OWLProfileViolation>(); violations.addAll(report.getViolations()); OWLOntologyWalker walker = new OWLOntologyWalker(ontology.getImportsClosure()); OWL2RLObjectVisitor visitor = new OWL2RLObjectVisitor(walker); walker.walkStructure(visitor); violations.addAll(visitor.getProfileViolations()); return new OWLProfileReport(this, violations); }
public static OWLOntology readOWLELOntology(String filePath) throws OWLOntologyCreationException { OWLOntology ont = readOWLOntology(filePath); OWLOntologyManager elMan = OWLManager.createOWLOntologyManager(); OWLOntology elOnt = elMan.createOntology(); OWL2ELProfile el = new OWL2ELProfile(); OWLProfileReport report = el.checkOntology(ont); HashSet<OWLAxiom> violatingAxioms = new HashSet<>(); for (OWLProfileViolation violation : report.getViolations()) { violatingAxioms.add(violation.getAxiom()); } for (OWLAxiom axiom : ont.getLogicalAxioms()) { if (!violatingAxioms.contains(axiom)) { elMan.addAxiom(elOnt, axiom); } } // IRI physicalModuleIRI = IRI.create(new File("/tmp/smallis/el_module.owl")); // elMan.saveOntology(elOnt, new RDFXMLOntologyFormat(), physicalModuleIRI); logger.info("-Done-"); return elOnt; }
/** * Checks an ontology and its import closure to see if it is within * this profile. * @param ontology The ontology to be checked. * @return An <code>OWLProfileReport</code> that describes whether or not the * ontology is within this profile. */ public OWLProfileReport checkOntology(OWLOntology ontology) { OWL2DLProfile profile = new OWL2DLProfile(); OWLProfileReport report = profile.checkOntology(ontology); Set<OWLProfileViolation> violations = new HashSet<OWLProfileViolation>(); violations.addAll(report.getViolations()); OWLOntologyWalker walker = new OWLOntologyWalker(ontology.getImportsClosure()); OWL2QLObjectVisitor visitor = new OWL2QLObjectVisitor(walker); walker.walkStructure(visitor); violations.addAll(visitor.getProfileViolations()); return new OWLProfileReport(this, violations); }
/** * Checks an ontology and its import closure to see if it is within * this profile. * @param ontology The ontology to be checked. * @return An <code>OWLProfileReport</code> that describes whether or not the * ontology is within this profile. */ public OWLProfileReport checkOntology(OWLOntology ontology) { OWL2Profile owl2Profile = new OWL2Profile(); OWLProfileReport report = owl2Profile.checkOntology(ontology); Set<OWLProfileViolation> violations = new LinkedHashSet<OWLProfileViolation>(); if(!report.isInProfile()) { //We won't be in the OWL 2 DL Profile then! violations.addAll(report.getViolations()); } OWLOntologyWalker walker = new OWLOntologyWalker(ontology.getImportsClosure()); OWL2DLProfileObjectVisitor visitor = new OWL2DLProfileObjectVisitor(walker, ontology.getOWLOntologyManager()); walker.walkStructure(visitor); violations.addAll(visitor.getProfileViolations()); return new OWLProfileReport(this, violations); }