Java源码示例:org.semanticweb.owlapi.model.OWLDeclarationAxiom

示例1
@Override
public T visit(OWLDeclarationAxiom axiom) {
	throw new IllegalArgumentException(
			OWLDeclarationAxiom.class.getSimpleName()
					+ " cannot be converted to "
					+ getTargetClass().getSimpleName());
}
 
示例2
public Set<OWLClass> extractClassesFromDeclarations(Set<OWLAxiom> axs) {
	Set<OWLClass> cs = new HashSet<OWLClass>();
	for (OWLAxiom ax : axs) {
		if (ax instanceof OWLDeclarationAxiom) {
			OWLEntity e = ((OWLDeclarationAxiom)ax).getEntity();
			if (e instanceof OWLClass)
				cs.add((OWLClass) e);
		}
	}
	return cs;
}
 
示例3
private static Set<OWLAxiom> filter(Set<OWLAxiom> axioms, Diff diff) {
    if (diff.isFilterDeclarations) {
        return axioms.stream().filter(a -> !(a instanceof OWLDeclarationAxiom)).
                collect(Collectors.toSet());
    }
    else {
        return axioms;
    }
}
 
示例4
/**
 * Returns an OWLNamedIndividual with this IRI <b>if it has been declared</b>
 * in the source or support ontologies. Returns null otherwise.
 * 
 * @param iri
 * @return {@link OWLNamedIndividual}
 */
public OWLNamedIndividual getOWLIndividual(IRI iri) {
	OWLNamedIndividual c = getDataFactory().getOWLNamedIndividual(iri);
	for (OWLOntology o : getAllOntologies()) {
		for (OWLDeclarationAxiom da : o.getDeclarationAxioms(c)) {
			if (da.getEntity() instanceof OWLNamedIndividual) {
				return (OWLNamedIndividual) da.getEntity();
			}
		}
	}
	return null;
}
 
示例5
/**
 * Convenience method for adding a declaration axiom to the ontology.
 *
 * @param ontology the current ontology
 * @param subject the entity for which the declaration will be added
 * @return the declaration axiom
 */
protected static OWLDeclarationAxiom declare(OWLOntology ontology,
		OWLEntity subject) {
	OWLOntologyManager manager = ontology.getOWLOntologyManager();
	OWLDataFactory dataFactory = manager.getOWLDataFactory();
	OWLDeclarationAxiom axiom = 
		dataFactory.getOWLDeclarationAxiom(subject);
	manager.addAxiom(ontology, axiom);
	return axiom;
}
 
示例6
/**
 * Extracts {@link PredicateVariableExtractor} rules.
 * 
 * @param ot ontology
 * @return extracted rules
 */
@Override
public List<Rule> extract(OWLOntology ot) {
	List<Rule> list = new ArrayList<>();
	// list of predicates in ontology
	List<String> ps = new ArrayList<>();
	ps.add(TOPOBJ);
	ps.add(TOPDATA);
	OWLEntity e;
	String op;
	// check all declarations
	for (OWLDeclarationAxiom a : ot.getAxioms(AxiomType.DECLARATION)) {
		e = a.getEntity();
		if (e.isOWLObjectProperty()) {
			// if it is a object property declaration, add it to the list
			// and also add it as subproperty of owl:topObjectProperty
			op = getString(e.asOWLObjectProperty());
			ps.add(op);
			list.add(new SubPropertyOf(op, TOPOBJ));
		} else if (e.isOWLDataProperty()) {
			// if it is a data property declaration, add it to the list
			// and also add it as subproperty of owl:topDataProperty
			op = getString(e.asOWLDataProperty());
			ps.add(op);
			list.add(new SubPropertyOf(op, TOPDATA));
		}
	}
	list.add(new PredicateVariable(ps));
	return list;
}
 
示例7
@Override
public Void visit(OWLDeclarationAxiom axiom) {
  String iri = getIri(axiom);
  long node = getOrCreateNode(iri);
  addDefinedBy(node);
  if (axiom.getEntity() instanceof OWLClass) {
    graph.addLabel(node, OwlLabels.OWL_CLASS);
  } else if (axiom.getEntity() instanceof OWLNamedIndividual) {
    graph.addLabel(node, OwlLabels.OWL_NAMED_INDIVIDUAL);
  } else if (axiom.getEntity() instanceof OWLObjectProperty) {
    if (!graph.getLabels(node).contains(OwlLabels.OWL_OBJECT_PROPERTY)) {
      graph.addLabel(node, OwlLabels.OWL_OBJECT_PROPERTY);
      if (ontology.isPresent()) {
        OWLObjectProperty property = (OWLObjectProperty) axiom.getEntity();
        graph.setNodeProperty(node, EdgeProperties.SYMMETRIC,
            !property.isAsymmetric(ontology.get()));
        graph.setNodeProperty(node, EdgeProperties.REFLEXIVE,
            property.isReflexive(ontology.get()));
        graph.setNodeProperty(node, EdgeProperties.TRANSITIVE,
            property.isTransitive(ontology.get()));
      }
    }
  } else if (axiom.getEntity() instanceof OWLDataProperty) {
    graph.setLabel(node, OwlLabels.OWL_DATA_PROPERTY);
  } else {
    // logger.warning("Unhandled declaration type " + axiom.getEntity().getClass().getName());
  }
  return null;
}
 
示例8
@Override
public OWLDeclarationAxiom visit(ElkDeclarationAxiom axiom) {
	return owlFactory_.getOWLDeclarationAxiom(convert(axiom.getEntity()));
}
 
示例9
@SuppressWarnings("static-method")
public ElkDeclarationAxiom convert(
		OWLDeclarationAxiom owlDeclarationAxiom) {
	return new ElkDeclarationAxiomWrap<OWLDeclarationAxiom>(
			owlDeclarationAxiom);
}
 
示例10
@Override
public ElkAxiom visit(OWLDeclarationAxiom owlDeclarationAxiom) {
	return CONVERTER.convert(owlDeclarationAxiom);
}
 
示例11
@Override
public void visit(OWLDeclarationAxiom axiom) {
	defaultVisit(axiom);
}
 
示例12
private void tr(OWLDeclarationAxiom ax) {
	// do nothing: instances and tlrs declared fresh
}
 
示例13
@Override
public OWLAxiom visit(OWLDeclarationAxiom axiom) {
	return factory.getOWLDeclarationAxiom(axiom.getEntity(), annotations);
}
 
示例14
@Override
public void visit(OWLDeclarationAxiom axiom) {
}
 
示例15
public static String getIri(OWLDeclarationAxiom expression) {
  return expression.getEntity().getIRI().toString();
}