public void visit(OWLDifferentIndividualsAxiom object) { OWLIndividual[] individuals = new OWLIndividual[object.getIndividuals().size()]; object.getIndividuals().toArray(individuals); for (int i = 0; i < individuals.length; i++) for (int j = i + 1; j < individuals.length; j++) { Atom atom = Atom.create( Inequality.create(), getIndividual(individuals[i]), getIndividual(individuals[j])); Collection<OWLAxiom> originalAxioms = m_positiveFacts_map.get(atom); if (originalAxioms == null) { originalAxioms = new ArrayList<OWLAxiom>(); m_positiveFacts_map.put(atom, originalAxioms); } if (originalAxiom != null) originalAxioms.add(originalAxiom); } }
public DLOntology_withMaps clausify_withMaps( OWLDataFactory factory, String ontologyIRI, OWLAxioms_withMaps axioms, OWLAxiomsExpressivity axiomsExpressivity) { Map<DLClause, Collection<OWLAxiom>> dlClauses = new HashMap<DLClause, Collection<OWLAxiom>>(); Map<Atom, Collection<OWLAxiom>> positiveFacts = new HashMap<Atom, Collection<OWLAxiom>>(); Map<Atom, Collection<OWLAxiom>> negativeFacts = new HashMap<Atom, Collection<OWLAxiom>>(); for (Entry<OWLAxiom, Collection<OWLObjectPropertyExpression[]>> entry : axioms.m_simpleObjectPropertyInclusions_map.entrySet()) { for (OWLObjectPropertyExpression[] inclusion : entry.getValue()) { Atom subRoleAtom = getRoleAtom(inclusion[0], X, Y); Atom superRoleAtom = getRoleAtom(inclusion[1], X, Y); DLClause dlClause = DLClause.create(new Atom[] {superRoleAtom}, new Atom[] {subRoleAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(entry.getKey()); } } for (Entry<OWLAxiom, Collection<OWLDataPropertyExpression[]>> entry : axioms.m_dataPropertyInclusions_map.entrySet()) { for (OWLDataPropertyExpression[] inclusion : entry.getValue()) { Atom subProp = getRoleAtom(inclusion[0], X, Y); Atom superProp = getRoleAtom(inclusion[1], X, Y); DLClause dlClause = DLClause.create(new Atom[] {superProp}, new Atom[] {subProp}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(entry.getKey()); } if (entry .getValue() .contains(factory.getOWLDataProperty(IRI.create(AtomicRole.BOTTOM_DATA_ROLE.getIRI())))) { Atom bodyAtom = Atom.create(AtomicRole.BOTTOM_DATA_ROLE, X, Y); DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {bodyAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(entry.getKey()); } } for (OWLObjectPropertyExpression objectPropertyExpression : axioms.m_symmetricObjectProperties) { Atom roleAtom = getRoleAtom(objectPropertyExpression, X, Y); Atom inverseRoleAtom = getRoleAtom(objectPropertyExpression, Y, X); DLClause dlClause = DLClause.create(new Atom[] {inverseRoleAtom}, new Atom[] {roleAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(factory.getOWLSymmetricObjectPropertyAxiom(objectPropertyExpression)); } for (OWLObjectPropertyExpression objectPropertyExpression : axioms.m_asymmetricObjectProperties) { Atom roleAtom = getRoleAtom(objectPropertyExpression, X, Y); Atom inverseRoleAtom = getRoleAtom(objectPropertyExpression, Y, X); DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {roleAtom, inverseRoleAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(factory.getOWLAsymmetricObjectPropertyAxiom(objectPropertyExpression)); } for (OWLObjectPropertyExpression objectPropertyExpression : axioms.m_reflexiveObjectProperties) { Atom roleAtom = getRoleAtom(objectPropertyExpression, X, X); Atom bodyAtom = Atom.create(AtomicConcept.THING, X); DLClause dlClause = DLClause.create(new Atom[] {roleAtom}, new Atom[] {bodyAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(factory.getOWLReflexiveObjectPropertyAxiom(objectPropertyExpression)); } for (OWLObjectPropertyExpression objectPropertyExpression : axioms.m_irreflexiveObjectProperties) { Atom roleAtom = getRoleAtom(objectPropertyExpression, X, X); DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {roleAtom}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(factory.getOWLIrreflexiveObjectPropertyAxiom(objectPropertyExpression)); } for (OWLObjectPropertyExpression[] properties : axioms.m_disjointObjectProperties) { OWLAxiom axiom = factory.getOWLDisjointObjectPropertiesAxiom(properties); for (int i = 0; i < properties.length; i++) for (int j = i + 1; j < properties.length; j++) { Atom atom_i = getRoleAtom(properties[i], X, Y); Atom atom_j = getRoleAtom(properties[j], X, Y); DLClause dlClause = DLClause.create(new Atom[] {}, new Atom[] {atom_i, atom_j}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(axiom); } } for (OWLDataPropertyExpression[] properties : axioms.m_disjointDataProperties) { OWLAxiom axiom = factory.getOWLDisjointDataPropertiesAxiom(properties); for (int i = 0; i < properties.length; i++) for (int j = i + 1; j < properties.length; j++) { Atom atom_i = getRoleAtom(properties[i], X, Y); Atom atom_j = getRoleAtom(properties[j], X, Z); Atom atom_ij = Atom.create(Inequality.create(), Y, Z); DLClause dlClause = DLClause.create(new Atom[] {atom_ij}, new Atom[] {atom_i, atom_j}); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(axiom); } } DataRangeConverter dataRangeConverter = new DataRangeConverter( m_configuration.warningMonitor, axioms.m_definedDatatypesIRIs, new HashSet<DatatypeRestriction>(), m_configuration.ignoreUnsupportedDatatypes); Set<Atom> auxiliaryFacts = new HashSet<Atom>(); NormalizedAxiomClausifier_withMaps clausifier = new NormalizedAxiomClausifier_withMaps(dataRangeConverter, auxiliaryFacts, factory); for (Entry<OWLAxiom, Collection<OWLClassExpression[]>> entry : axioms.m_conceptInclusions_map.entrySet()) for (OWLClassExpression[] inclusion : entry.getValue()) { for (OWLClassExpression description : inclusion) description.accept(clausifier); DLClause dlClause = clausifier.getDLClause().getSafeVersion(AtomicConcept.THING); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } correspAxioms.add(entry.getKey()); } for (OWLClassExpression[] inclusion : axioms.m_auxiliaryConceptInclusions) { for (OWLClassExpression description : inclusion) description.accept(clausifier); DLClause dlClause = clausifier.getDLClause().getSafeVersion(AtomicConcept.THING); Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); if (correspAxioms == null) { correspAxioms = new ArrayList<OWLAxiom>(); dlClauses.put(dlClause, correspAxioms); } } // NormalizedDataRangeAxiomClausifier_withMaps normalizedDataRangeAxiomClausifier=new // NormalizedDataRangeAxiomClausifier_withMaps(dataRangeConverter,factory,axioms.m_definedDatatypesIRIs); // // for (Entry<OWLAxiom,Collection<OWLDataRange[]>> entry : // axioms.m_dataRangeInclusions_map.entrySet()) { // for (OWLDataRange[] inclusion : entry.getValue()) { // for (OWLDataRange description : inclusion) // description.accept(normalizedDataRangeAxiomClausifier); // DLClause // dlClause=normalizedDataRangeAxiomClausifier.getDLClause().getSafeVersion(InternalDatatype.RDFS_LITERAL); // Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); // if (correspAxioms == null) { // correspAxioms = new ArrayList<OWLAxiom>(); // dlClauses.put(dlClause, correspAxioms); // } // correspAxioms.add(entry.getKey()); // } // } // for (OWLDataRange[] inclusion : axioms.m_auxiliaryDataRangeInclusions) { // for (OWLDataRange description : inclusion) // description.accept(normalizedDataRangeAxiomClausifier); // DLClause // dlClause=normalizedDataRangeAxiomClausifier.getDLClause().getSafeVersion(InternalDatatype.RDFS_LITERAL); // Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); // if (correspAxioms == null) { // correspAxioms = new ArrayList<OWLAxiom>(); // dlClauses.put(dlClause, correspAxioms); // } // } // for (Entry<OWLAxiom,OWLHasKeyAxiom> entry : axioms.m_hasKeys_map.entrySet()) { // DLClause dlClause = clausifyKey(entry.getValue()); // Collection<OWLAxiom> correspAxioms = dlClauses.get(dlClause); // if (correspAxioms == null) { // correspAxioms = new ArrayList<OWLAxiom>(); // dlClauses.put(dlClause, correspAxioms); // } // correspAxioms.add(entry.getKey()); // } FactClausifier_withMaps factClausifier = new FactClausifier_withMaps(dataRangeConverter, positiveFacts, negativeFacts); for (Entry<OWLAxiom, Collection<OWLIndividualAxiom>> entry : axioms.m_facts_map.entrySet()) for (OWLIndividualAxiom fact : entry.getValue()) factClausifier.process(entry.getKey(), fact); for (Atom atom : auxiliaryFacts) { Collection<OWLAxiom> originalAxioms = positiveFacts.get(atom); if (originalAxioms == null) { originalAxioms = new ArrayList<OWLAxiom>(); positiveFacts.put(atom, originalAxioms); } } // OWLLiteral[] literals = new OWLLiteral[axioms.m_literals.size()]; // int i = 0; // for (OWLLiteral lit : axioms.m_literals) // literals[i++] = lit; // for (i = 0; i<literals.length; i++) // for (int j = i+1; j<literals.length; j++) { // factClausifier.process(null, // factory.getOWLDifferentIndividualsAxiom(factory.getOWLNamedIndividual(IRI.create(literals[i].toString())), factory.getOWLNamedIndividual(IRI.create(literals[j].toString())))); // // positiveFacts.put(Atom.create(Inequality.INSTANCE, literals[i], literals[j]), // new ArrayList<OWLAxiom>()); // } Set<Individual> individuals = new HashSet<Individual>(); for (OWLNamedIndividual owlIndividual : axioms.m_namedIndividuals) { Individual individual = Individual.create(owlIndividual.getIRI().toString()); individuals.add(individual); // all named individuals are tagged with a concept, so that keys/rules are // only applied to them if (!axioms.m_hasKeys.isEmpty() || !axioms.m_rules.isEmpty()) { Atom atom = Atom.create(AtomicConcept.INTERNAL_NAMED, individual); Collection<OWLAxiom> originalAxioms = positiveFacts.get(atom); if (originalAxioms == null) { originalAxioms = new ArrayList<OWLAxiom>(); positiveFacts.put(atom, originalAxioms); } } } // Clausify SWRL rules if (!axioms.m_rules.isEmpty()) new NormalizedRuleClausifier_withMaps( axioms.m_objectPropertiesOccurringInOWLAxioms, dataRangeConverter, dlClauses) .processRules(axioms.m_rules_map); // Create the DL ontology return new DLOntology_withMaps(dlClauses, positiveFacts, negativeFacts, axioms.m_literals); }