public OWLAxioms() { m_classes=new HashSet<OWLClass>(); m_objectProperties=new HashSet<OWLObjectProperty>(); m_objectPropertiesOccurringInOWLAxioms=new HashSet<OWLObjectProperty>(); m_complexObjectPropertyExpressions=new HashSet<OWLObjectPropertyExpression>(); m_dataProperties=new HashSet<OWLDataProperty>(); m_namedIndividuals=new HashSet<OWLNamedIndividual>(); m_conceptInclusions=new ArrayList<OWLClassExpression[]>(); m_dataRangeInclusions=new ArrayList<OWLDataRange[]>(); m_simpleObjectPropertyInclusions=new ArrayList<OWLObjectPropertyExpression[]>(); m_complexObjectPropertyInclusions=new ArrayList<ComplexObjectPropertyInclusion>(); m_disjointObjectProperties=new ArrayList<OWLObjectPropertyExpression[]>(); m_reflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_irreflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_asymmetricObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_disjointDataProperties=new ArrayList<OWLDataPropertyExpression[]>(); m_dataPropertyInclusions=new ArrayList<OWLDataPropertyExpression[]>(); m_facts=new HashSet<OWLIndividualAxiom>(); m_hasKeys=new HashSet<OWLHasKeyAxiom>(); m_definedDatatypesIRIs=new HashSet<String>(); m_rules=new HashSet<DisjunctiveRule>(); }
public void visit(SWRLDataRangeAtom at) { OWLDataRange dr=at.getPredicate(); SWRLDArgument argument=at.getArgument(); if (!(argument instanceof SWRLVariable)) throw new IllegalArgumentException("A SWRL rule contains a data range with an argument that is not a literal, and such rules are not supported."); if (!m_isPositive) dr=m_factory.getOWLDataComplementOf(dr); dr=m_expressionManager.getNNF(m_expressionManager.getSimplified(dr)); if (dr instanceof OWLDataIntersectionOf || dr instanceof OWLDataUnionOf) { OWLDatatype definition=getDefinitionFor(dr,m_alreadyExists); if (!m_alreadyExists[0]) m_dataRangeInclusions.add(new OWLDataRange[] { negative(definition),dr }); dr=definition; } SWRLAtom atom=m_factory.getSWRLDataRangeAtom(dr,argument); m_normalizedHeadAtoms.add(atom); m_headDataRangeVariables.add((SWRLVariable)argument); }
public void visit(OWLDataComplementOf dr) { OWLDataRange description=dr.getDataRange(); if (description.isDatatype() && (Prefixes.isInternalIRI(description.asOWLDatatype().getIRI().toString()) || m_definedDatatypeIRIs.contains(description.asOWLDatatype()))) { m_bodyAtoms.add(Atom.create(InternalDatatype.create(description.asOWLDatatype().getIRI().toString()),X)); } else { LiteralDataRange literalRange=m_dataRangeConverter.convertDataRange(dr); if (literalRange.isNegatedInternalDatatype()) { InternalDatatype negatedDatatype=(InternalDatatype)literalRange.getNegation(); if (!negatedDatatype.isAlwaysTrue()) m_bodyAtoms.add(Atom.create(negatedDatatype,X)); } else { if (!literalRange.isAlwaysFalse()) m_headAtoms.add(Atom.create((DLPredicate)literalRange,X)); } } }
public OWLAxioms() { m_classes=new HashSet<OWLClass>(); m_objectProperties=new HashSet<OWLObjectProperty>(); m_objectPropertiesOccurringInOWLAxioms=new HashSet<OWLObjectProperty>(); m_complexObjectPropertyExpressions=new HashSet<OWLObjectPropertyExpression>(); m_dataProperties=new HashSet<OWLDataProperty>(); m_namedIndividuals=new HashSet<OWLNamedIndividual>(); m_aspConstraints=new HashSet<ASPConstraint>(); m_aspRules=new HashSet<ASPRule>(); m_conceptInclusions=new ArrayList<OWLClassExpression[]>(); m_dataRangeInclusions=new ArrayList<OWLDataRange[]>(); m_simpleObjectPropertyInclusions=new ArrayList<OWLObjectPropertyExpression[]>(); m_complexObjectPropertyInclusions=new ArrayList<ComplexObjectPropertyInclusion>(); m_disjointObjectProperties=new ArrayList<OWLObjectPropertyExpression[]>(); m_reflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_irreflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_asymmetricObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_disjointDataProperties=new ArrayList<OWLDataPropertyExpression[]>(); m_dataPropertyInclusions=new ArrayList<OWLDataPropertyExpression[]>(); m_facts=new HashSet<OWLIndividualAxiom>(); m_hasKeys=new HashSet<OWLHasKeyAxiom>(); m_definedDatatypesIRIs=new HashSet<String>(); m_rules=new HashSet<DisjunctiveRule>(); }
public OWLNormalization(OWLDataFactory factory,OWLAxioms axioms,int firstReplacementIndex) { m_factory=factory; m_axioms=axioms; m_firstReplacementIndex=firstReplacementIndex; m_definitions=new HashMap<OWLClassExpression,OWLClassExpression>(); m_definitionsForNegativeNominals=new HashMap<OWLObjectOneOf,OWLClass>(); m_expressionManager=new ExpressionManager(m_factory); m_plVisitor=new PLVisitor(); m_dataRangeDefinitions=new HashMap<OWLDataRange,OWLDatatype>(); }
public OWLClassExpression visit(OWLDataMinCardinality d) { OWLDataRange filler=getSimplified(d.getFiller()); if (d.getCardinality()<=0) return m_factory.getOWLThing(); else if (isBottomDataRange(filler)) return m_factory.getOWLNothing(); else if (d.getCardinality()==1) return m_factory.getOWLDataSomeValuesFrom(d.getProperty(),filler); else return m_factory.getOWLDataMinCardinality(d.getCardinality(),d.getProperty(),filler); }
public void visit(OWLClassAssertionAxiom axiom) { OWLClassExpression classExpression=axiom.getClassExpression(); if (classExpression instanceof OWLDataHasValue) { OWLDataHasValue hasValue=(OWLDataHasValue)classExpression; addFact(m_factory.getOWLDataPropertyAssertionAxiom(hasValue.getProperty(), axiom.getIndividual(), hasValue.getValue())); return; } if (classExpression instanceof OWLDataSomeValuesFrom) { OWLDataSomeValuesFrom someValuesFrom=(OWLDataSomeValuesFrom)classExpression; OWLDataRange dataRange=someValuesFrom.getFiller(); if (dataRange instanceof OWLDataOneOf) { OWLDataOneOf oneOf=(OWLDataOneOf)dataRange; if (oneOf.getValues().size()==1) { addFact(m_factory.getOWLDataPropertyAssertionAxiom(someValuesFrom.getProperty(),axiom.getIndividual(),oneOf.getValues().iterator().next())); return; } } } classExpression=positive(classExpression); if (!isSimple(classExpression)) { OWLClassExpression definition=getDefinitionFor(classExpression,m_alreadyExists); if (!m_alreadyExists[0]) m_classExpressionInclusionsAsDisjunctions.add(new OWLClassExpression[] { negative(definition),classExpression }); classExpression=definition; } addFact(m_factory.getOWLClassAssertionAxiom(classExpression,axiom.getIndividual())); }
public OWLClassExpression visit(OWLDataMinCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataMinCardinality(object.getCardinality(),prop,definition); } }
protected OWLDatatype getDefinitionFor(OWLDataRange dr,boolean[] alreadyExists) { OWLDatatype definition=m_dataRangeDefinitions.get(dr); if (definition==null) { definition=m_factory.getOWLDatatype(IRI.create("internal:defdata#"+m_dataRangeDefinitions.size())); m_dataRangeDefinitions.put(dr,definition); alreadyExists[0]=false; } else { alreadyExists[0]=true; } return definition; }
public OWLClassExpression visit(OWLDataExactCardinality d) { OWLDataRange filler=getSimplified(d.getFiller()); if (d.getCardinality()<0) return m_factory.getOWLNothing(); else if (d.getCardinality()==0) return m_factory.getOWLDataAllValuesFrom(d.getProperty(),m_factory.getOWLDataComplementOf(filler)); else if (isBottomDataRange(filler)) return m_factory.getOWLNothing(); else { OWLDataMinCardinality minCardinality=m_factory.getOWLDataMinCardinality(d.getCardinality(),d.getProperty(),filler); OWLDataMaxCardinality maxCardinality=m_factory.getOWLDataMaxCardinality(d.getCardinality(),d.getProperty(),filler); return m_factory.getOWLObjectIntersectionOf(minCardinality,maxCardinality); } }
public OWLDataRange visit(OWLDataComplementOf o) { OWLDataRange dataRangeSimplified=getSimplified(o.getDataRange()); if (dataRangeSimplified instanceof OWLDataComplementOf) return ((OWLDataComplementOf)dataRangeSimplified).getDataRange(); else return m_factory.getOWLDataComplementOf(dataRangeSimplified); }
public OWLDataRange visit(OWLDataUnionOf range) { Set<OWLDataRange> newDisjuncts=new HashSet<OWLDataRange>(); for (OWLDataRange dr : range.getOperands()) { OWLDataRange drSimplified=getSimplified(dr); if (drSimplified.isTopDatatype()) return m_factory.getTopDatatype(); else if (drSimplified instanceof OWLDataUnionOf) newDisjuncts.addAll(((OWLDataUnionOf)drSimplified).getOperands()); else newDisjuncts.add(drSimplified); } return m_factory.getOWLDataUnionOf(newDisjuncts); }
public OWLClassExpression visit(OWLDataMaxCardinality d) { OWLDataRange filler=getSimplified(d.getFiller()); if (isBottomDataRange(filler)) return m_factory.getOWLThing(); else if (d.getCardinality()<=0) return m_factory.getOWLDataAllValuesFrom(d.getProperty(),m_factory.getOWLDataComplementOf(filler)); else return m_factory.getOWLDataMaxCardinality(d.getCardinality(),d.getProperty(),filler); }
public OWLDataRange visit(OWLDataIntersectionOf range) { Set<OWLDataRange> newConjuncts=new HashSet<OWLDataRange>(); for (OWLDataRange dr : range.getOperands()) { OWLDataRange drSimplified=getSimplified(dr); if (drSimplified.isTopDatatype()) continue; else if (drSimplified instanceof OWLDataIntersectionOf) newConjuncts.addAll(((OWLDataIntersectionOf)drSimplified).getOperands()); else newConjuncts.add(drSimplified); } return m_factory.getOWLDataIntersectionOf(newConjuncts); }
Set<OWLDataRange> toDataRangeSet(List<? extends ElkDataRange> input) { Set<OWLDataRange> result = new HashSet<OWLDataRange>(input.size()); for (ElkDataRange next : input) { result.add(convert(next)); } return result; }
@Override public OWLDataRange convert(ElkDataRange input) { if (input instanceof ElkDataRangeWrap<?>) { return ((ElkDataRangeWrap<?>) input).getOwlObject(); } // else return (OWLDataRange) input.accept(this); }
public OWLNormalization(OWLDataFactory factory,OWLAxioms axioms,int firstReplacementIndex) { m_factory=factory; m_axioms=axioms; m_firstReplacementIndex=firstReplacementIndex; m_definitions=new HashMap<OWLClassExpression,OWLClassExpression>(); m_definitionsForNegativeNominals=new HashMap<OWLObjectOneOf,OWLClass>(); m_expressionManager=new ExpressionManager(m_factory); m_plVisitor=new PLVisitor(); m_dataRangeDefinitions=new HashMap<OWLDataRange,OWLDatatype>(); m_domain = new HashSet<OWLNamedIndividual>(); }
public void visit(OWLDataPropertyDomainAxiom axiom) { OWLDataPropertyExpression dataProperty=axiom.getProperty(); checkTopDataPropertyUse(dataProperty,axiom); OWLDataRange dataNothing=m_factory.getOWLDataComplementOf(m_factory.getTopDatatype()); OWLDataAllValuesFrom allPropertyDataNothing=m_factory.getOWLDataAllValuesFrom(dataProperty,dataNothing); m_classExpressionInclusionsAsDisjunctions.add(new OWLClassExpression[] { positive(axiom.getDomain()),allPropertyDataNothing }); }
public OWLClassExpression visit(OWLDataSomeValuesFrom object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),filler); else { OWLDatatype definition=getDefinitionFor(filler,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataSomeValuesFrom(object.getProperty(),definition); } }
public OWLClassExpression visit(OWLDataMaxCardinality object) { OWLDataRange filler=object.getFiller(); OWLDataPropertyExpression prop=object.getProperty(); if (prop.isOWLTopDataProperty()) throwInvalidTopDPUseError(object); if (isLiteral(filler)) return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,filler); else { OWLDataRange complementDescription=m_expressionManager.getComplementNNF(filler); OWLDatatype definition=getDefinitionFor(complementDescription,m_alreadyExists); if (!m_alreadyExists[0]) m_newDataRangeInclusions.add(new OWLDataRange[] { negative(definition),filler }); return m_factory.getOWLDataMaxCardinality(object.getCardinality(),prop,m_expressionManager.getComplementNNF(definition)); } }
protected void addToGenericDomainAndNewRange(OWLDataProperty property, OWLDataRange range) { OWLClass domain = featurePool.getReusableClass(); addProperty(domain, property, range); }
protected void addProperty(OWLClass domain, OWLDataProperty property, OWLDataRange range) { addAxiomToOntology(factory.getOWLDataPropertyDomainAxiom(property, domain)); addAxiomToOntology(factory.getOWLDataPropertyRangeAxiom(property, range)); }
protected static boolean isLiteral(OWLDataRange dr) { return isAtomic(dr) || isNegatedAtomic(dr); }
public void visit(OWLDatatypeDefinitionAxiom axiom) { m_axioms.m_definedDatatypesIRIs.add(axiom.getDatatype().getIRI().toString()); m_dataRangeInclusionsAsDisjunctions.add(new OWLDataRange[] { negative(axiom.getDatatype()),positive(axiom.getDataRange()) }); m_dataRangeInclusionsAsDisjunctions.add(new OWLDataRange[] { negative(axiom.getDataRange()),positive(axiom.getDatatype()) }); }
protected static boolean isAtomic(OWLDataRange dr) { return dr instanceof OWLDatatype || dr instanceof OWLDatatypeRestriction || dr instanceof OWLDataOneOf; }
protected OWLDataRange positive(OWLDataRange dataRange) { return m_expressionManager.getNNF(m_expressionManager.getSimplified(dataRange)); }
public OWLDataRange visit(OWLDatatypeRestriction o) { return m_factory.getOWLDataComplementOf(o); }
public OWLDataRange visit(OWLDataOneOf o) { return o; }