@Test public void testParseClazzNegatedExpression() throws Exception { JsonOwlObject svf = new JsonOwlObject(); svf.type = JsonOwlObjectType.SomeValueFrom; svf.property = new JsonOwlObject(); svf.property.type = JsonOwlObjectType.ObjectProperty; svf.property.id = OCCURS_IN; // occurs_in svf.filler = new JsonOwlObject(); svf.filler.id = NUCLEUS; svf.filler.type = JsonOwlObjectType.Class; JsonOwlObject expression = new JsonOwlObject(); expression.type = JsonOwlObjectType.ComplementOf; expression.filler = svf; OWLDataFactory df = graph.getDataFactory(); OWLClassExpression ce = new M3ExpressionParser(curieHandler).parse(graph, expression, null); OWLClass nucleus = graph.getOWLClassByIdentifier(NUCLEUS); OWLObjectSomeValuesFrom svfx = df.getOWLObjectSomeValuesFrom(graph.getOWLObjectPropertyByIdentifier(OCCURS_IN), nucleus); OWLObjectComplementOf ceExpected = df.getOWLObjectComplementOf(svfx); assertEquals(ceExpected, ce); }
public void visit(OWLObjectComplementOf object) { OWLClassExpression description=object.getOperand(); if (description instanceof OWLObjectHasSelf) { OWLObjectPropertyExpression objectProperty=((OWLObjectHasSelf)description).getProperty(); Atom roleAtom=getRoleAtom(objectProperty,X,X); m_bodyAtoms.add(roleAtom); } else if (description instanceof OWLObjectOneOf && ((OWLObjectOneOf)description).getIndividuals().size()==1) { OWLIndividual individual=((OWLObjectOneOf)description).getIndividuals().iterator().next(); m_bodyAtoms.add(Atom.create(getConceptForNominal(individual),X)); } else if (!(description instanceof OWLClass)) throw new IllegalStateException("Internal error: invalid normal form."); else m_bodyAtoms.add(Atom.create(AtomicConcept.create(((OWLClass)description).getIRI().toString()),X)); }
@Override public void addToOntology() { OWLClass nonComplement = featurePool.getExclusiveClass(":NoObjectComplementOf"); OWLObjectComplementOf complement = factory.getOWLObjectComplementOf(nonComplement); OWLClass owlClass = featurePool.getExclusiveClass(":ObjectComplementOf"); addAxiomToOntology(factory.getOWLSubClassOfAxiom(owlClass, complement)); }
@Test public void testParseClazzNegated() throws Exception { JsonOwlObject expression = new JsonOwlObject(); expression.type = JsonOwlObjectType.ComplementOf; expression.filler = new JsonOwlObject(); expression.filler.id = NUCLEUS; expression.filler.type = JsonOwlObjectType.Class; OWLClassExpression ce = new M3ExpressionParser(curieHandler).parse(graph, expression, null); OWLClass nucleus = graph.getOWLClassByIdentifier(NUCLEUS); OWLObjectComplementOf ceExpected = graph.getDataFactory().getOWLObjectComplementOf(nucleus); assertEquals(ceExpected, ce); }
protected static boolean isNegatedOneNominal(OWLClassExpression description) { if (!(description instanceof OWLObjectComplementOf)) return false; OWLClassExpression operand=((OWLObjectComplementOf)description).getOperand(); if (!(operand instanceof OWLObjectOneOf)) return false; return ((OWLObjectOneOf)operand).getIndividuals().size()==1; }
public OWLClassExpression visit(OWLObjectComplementOf object) { if (isNominal(object.getOperand())) { OWLObjectOneOf objectOneOf=(OWLObjectOneOf)object.getOperand(); OWLClass definition=getDefinitionForNegativeNominal(objectOneOf,m_alreadyExists); if (!m_alreadyExists[0]) for (OWLIndividual individual : objectOneOf.getIndividuals()) addFact(m_factory.getOWLClassAssertionAxiom(definition,individual)); return m_factory.getOWLObjectComplementOf(definition); } else return object; }
public OWLClassExpression visit(OWLObjectComplementOf d) { OWLClassExpression operandSimplified=getSimplified(d.getOperand()); if (operandSimplified.isOWLThing()) return m_factory.getOWLNothing(); else if (operandSimplified.isOWLNothing()) return m_factory.getOWLThing(); else if (operandSimplified instanceof OWLObjectComplementOf) return ((OWLObjectComplementOf)operandSimplified).getOperand(); else return m_factory.getOWLObjectComplementOf(operandSimplified); }
protected static LiteralConcept getLiteralConcept(OWLClassExpression description) { if (description instanceof OWLClass) { return AtomicConcept.create(((OWLClass)description).getIRI().toString()); } else if (description instanceof OWLObjectComplementOf) { OWLClassExpression internal=((OWLObjectComplementOf)description).getOperand(); if (!(internal instanceof OWLClass)) throw new IllegalStateException("Internal error: invalid normal form."); return AtomicConcept.create(((OWLClass)internal).getIRI().toString()).getNegation(); } else throw new IllegalStateException("Internal error: invalid normal form."); }
@Override public OWLObjectComplementOf visit(OWLObjectComplementOf ce) { if (LOG.isDebugEnabled()) { LOG.debug("Unfolding complement_of: "+ce); } OWLClassExpression operand = ce.getOperand(); if (operand != null) { OWLClassExpression unfold = operand.accept(this); if (unfold != null) { return factory.getOWLObjectComplementOf(unfold); } } return null; }
public OWLClassExpression visit(OWLObjectComplementOf object) { if (isNominal(object.getOperand())) { OWLObjectOneOf objectOneOf=(OWLObjectOneOf)object.getOperand(); OWLClass definition=getDefinitionForNegativeNominal(objectOneOf,m_alreadyExists); if (!m_alreadyExists[0]) { for (OWLIndividual individual : objectOneOf.getIndividuals()) { addFact(m_factory.getOWLClassAssertionAxiom(definition,individual)); } } return m_factory.getOWLObjectComplementOf(definition); } else return object; }
/** * We assume that we deal with a normalized axioms, i.e. they are in NNF and structural transformation took place. * * Thereofre we test here whether the operand * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf) */ public void visit(OWLObjectComplementOf objComplementOf) { OWLClassExpression operand = objComplementOf.getOperand(); if (operand instanceof OWLClass) { OWLClass owlClass = operand.asOWLClass(); String predicateName = mapper.getPredicateName(owlClass); writer.print(predicateName); writer.print(ASP2CoreSymbols.BRACKET_OPEN); writer.print(var.currentVar()); writer.print(ASP2CoreSymbols.BRACKET_CLOSE); if (isAuxiliaryClass(owlClass)) auxClasses.add(owlClass); } // else if (operand instanceof OWLObjectHasSelf) { OWLObjectHasSelf owlHasSelf = (OWLObjectHasSelf) operand; OWLObjectProperty property = owlHasSelf.getProperty().asOWLObjectProperty(); String propertyName = mapper.getPredicateName(property); String cVar = var.currentVar(); // r(X,X) writer.print(propertyName); writer.print(ASP2CoreSymbols.BRACKET_OPEN); writer.print(cVar); writer.print(ASP2CoreSymbols.ARG_SEPERATOR); writer.print(cVar); writer.print(ASP2CoreSymbols.BRACKET_CLOSE); } else if (operand instanceof OWLObjectOneOf) { throw new NotImplementedException(); } }
/** * We assume that we deal with a normalized axioms, i.e. they are in NNF and structural transformation took place. * * Thereofre we test here whether the operand * @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf) */ public void visit(OWLObjectComplementOf objComplementOf) { OWLClassExpression operand = objComplementOf.getOperand(); if (operand instanceof OWLClass) { OWLClass owlClass = operand.asOWLClass(); String predicateName = mapper.getPredicateName(owlClass); writer.print(predicateName); writer.print(ASP2CoreSymbols.BRACKET_OPEN); writer.print(var.currentVar()); writer.print(ASP2CoreSymbols.BRACKET_CLOSE); if (isAuxiliaryClass(owlClass)) auxClasses.add(owlClass); } else if (operand instanceof OWLObjectHasSelf) { OWLObjectHasSelf owlHasSelf = (OWLObjectHasSelf) operand; OWLObjectProperty property = owlHasSelf.getProperty().asOWLObjectProperty(); String propertyName = mapper.getPredicateName(property); String cVar = var.currentVar(); // r(X,X) writer.print(propertyName); writer.print(ASP2CoreSymbols.BRACKET_OPEN); writer.print(cVar); writer.print(ASP2CoreSymbols.ARG_SEPERATOR); writer.print(cVar); writer.print(ASP2CoreSymbols.BRACKET_CLOSE); } else if (operand instanceof OWLObjectOneOf) { throw new NotImplementedException(); } }
@Override public Void visit(OWLObjectComplementOf desc) { long subject = getOrCreateNode(getIri(desc), OwlLabels.OWL_COMPLEMENT_OF, OwlLabels.OWL_ANONYMOUS); long operand = getOrCreateNode(getIri(desc.getOperand())); getOrCreateRelationship(subject, operand, OwlRelationships.OPERAND); return null; }
@Override public OWLClassExpression visit(OWLObjectComplementOf ce) { OWLClassExpression operand = ce.getOperand(); OWLClassExpression shortendedOperand = operand.accept(this); if(shortendedOperand.isOWLThing()){// \neg \top \equiv \bot return df.getOWLNothing(); } else if(shortendedOperand.isOWLNothing()){// \neg \bot \equiv \top return df.getOWLThing(); } else if(operand != shortendedOperand){ return df.getOWLObjectComplementOf(shortendedOperand); } return ce; }
@Override public Set<OWLClassExpression> visit(OWLObjectComplementOf ce) { Set<OWLClassExpression> result = new HashSet<>(); result.add(ce); result.addAll(ce.getOperand().accept(this)); return result; }
@Override public boolean equals(Object obj) { if (!(obj instanceof OWLObjectComplementOf)) { return false; } return ((OWLObjectComplementOf) obj).getOperand().equals(operand); }
public void visit(OWLObjectComplementOf arg0) { notSupported(arg0); }
public void visit(OWLObjectComplementOf object) { object.getOperand().accept(this); }
protected static boolean isSimple(OWLClassExpression description) { return description instanceof OWLClass || (description instanceof OWLObjectComplementOf && ((OWLObjectComplementOf)description).getOperand() instanceof OWLClass); }
public Boolean visit(OWLObjectComplementOf object) { return Boolean.FALSE; }
public OWLClassExpression visit(OWLObjectComplementOf d) { return getComplementNNF(d.getOperand()); }
public OWLClassExpression visit(OWLObjectComplementOf d) { return getNNF(d.getOperand()); }
public void visit(OWLObjectMaxCardinality object) { int cardinality=object.getCardinality(); OWLObjectPropertyExpression onObjectProperty=object.getProperty(); OWLClassExpression filler=object.getFiller(); ensureYNotZero(); boolean isPositive; AtomicConcept atomicConcept; if (filler instanceof OWLClass) { isPositive=true; atomicConcept=AtomicConcept.create(((OWLClass)filler).getIRI().toString()); if (atomicConcept.isAlwaysTrue()) atomicConcept=null; } else if (filler instanceof OWLObjectComplementOf) { OWLClassExpression internal=((OWLObjectComplementOf)filler).getOperand(); if (!(internal instanceof OWLClass)) throw new IllegalStateException("Internal error: Invalid ontology normal form."); isPositive=false; atomicConcept=AtomicConcept.create(((OWLClass)internal).getIRI().toString()); if (atomicConcept.isAlwaysFalse()) atomicConcept=null; } else throw new IllegalStateException("Internal error: Invalid ontology normal form."); Role onRole=getRole(onObjectProperty); LiteralConcept toConcept=getLiteralConcept(filler); AnnotatedEquality annotatedEquality=AnnotatedEquality.create(cardinality,onRole,toConcept); Variable[] yVars=new Variable[cardinality+1]; for (int i=0;i<yVars.length;i++) { yVars[i]=nextY(); m_bodyAtoms.add(getRoleAtom(onObjectProperty,X,yVars[i])); if (atomicConcept!=null) { Atom atom=Atom.create(atomicConcept,yVars[i]); if (isPositive) m_bodyAtoms.add(atom); else m_headAtoms.add(atom); } } // Node ID comparisons are not needed in case of functionality axioms, // as the effect of these is simulated by the way in which the rules are applied. if (yVars.length>2) { for (int i=0;i<yVars.length-1;i++) m_bodyAtoms.add(Atom.create(NodeIDLessEqualThan.INSTANCE,yVars[i],yVars[i+1])); m_bodyAtoms.add(Atom.create(NodeIDsAscendingOrEqual.create(yVars.length),yVars)); } for (int i=0;i<yVars.length;i++) for (int j=i+1;j<yVars.length;j++) m_headAtoms.add(Atom.create(annotatedEquality,yVars[i],yVars[j],X)); }
@Override public OWLObjectComplementOf visit(ElkObjectComplementOf expression) { return owlFactory_.getOWLObjectComplementOf( convert(expression.getClassExpression())); }
@Override public ElkObjectComplementOf visit( OWLObjectComplementOf owlObjectComplementOf) { return CONVERTER.convert(owlObjectComplementOf); }
@SuppressWarnings("static-method") public ElkObjectComplementOf convert( OWLObjectComplementOf owlObjectComplementOf) { return new ElkObjectComplementOfWrap<OWLObjectComplementOf>( owlObjectComplementOf); }