Java Code Examples for org.semanticweb.owlapi.model.OWLOntology#getClassAssertionAxioms()

The following examples show how to use org.semanticweb.owlapi.model.OWLOntology#getClassAssertionAxioms() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Sim2CommandRunner.java    From owltools with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@CLIMethod("--remove-dangling-annotations")
public void removeDangningAnnotations(Opts opts) throws Exception {
	OWLOntology ont = g.getSourceOntology();
	int n = 0;
	Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
	for (OWLNamedIndividual i : ont.getIndividualsInSignature()) {
		for (OWLClassAssertionAxiom ca : ont.getClassAssertionAxioms(i)) {
			OWLClassExpression cx = ca.getClassExpression();
			if (cx instanceof OWLClass) {
				OWLClass c = (OWLClass) cx;
				String label = g.getLabel(c);
				if (label == null)
					rmAxioms.add(ca);
				else
					n++;
			}
		}
	}
	LOG.info("Removing " + rmAxioms.size() + " axioms");
	ont.getOWLOntologyManager().removeAxioms(ont, rmAxioms);
	LOG.info("Remaining: " + n + " axioms");
}
 
Example 2
Source File: OwlHelper.java    From owltools with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Set<OWLClassExpression> getTypes(OWLNamedIndividual i, OWLOntology ont) {
	Set<OWLClassExpression> types;
	if (i != null && ont != null) {
		types = new HashSet<>();
		for (OWLClassAssertionAxiom axiom : ont.getClassAssertionAxioms(i)) {
			types.add(axiom.getClassExpression());
		}
	}
	else {
		types = Collections.emptySet();
	}
	return types;
}