public void visit(OWLSubPropertyChainOfAxiom axiom) { List<OWLObjectPropertyExpression> subPropertyChain=axiom.getPropertyChain(); if (!containsBottomObjectProperty(subPropertyChain) && !axiom.getSuperProperty().isOWLTopObjectProperty()) { OWLObjectPropertyExpression superObjectPropertyExpression=axiom.getSuperProperty(); if (subPropertyChain.size()==1) addInclusion(subPropertyChain.get(0),superObjectPropertyExpression); else if (subPropertyChain.size()==2 && subPropertyChain.get(0).equals(superObjectPropertyExpression) && subPropertyChain.get(1).equals(superObjectPropertyExpression)) makeTransitive(axiom.getSuperProperty()); else if (subPropertyChain.size()==0) throw new IllegalArgumentException("Error: In OWL 2 DL, an empty property chain in property chain axioms is not allowd, but the ontology contains an axiom that the empty chain is a subproperty of "+superObjectPropertyExpression+"."); else { OWLObjectPropertyExpression[] subObjectProperties=new OWLObjectPropertyExpression[subPropertyChain.size()]; subPropertyChain.toArray(subObjectProperties); addInclusion(subObjectProperties,superObjectPropertyExpression); } } for (OWLObjectPropertyExpression objectPropertyExpression : subPropertyChain) m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(objectPropertyExpression.getNamedProperty()); m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(axiom.getSuperProperty().getNamedProperty()); }
public Set<List<OWLObjectPropertyExpression>> getPropertyChains(OWLObjectProperty p) { LOG.info("Getting chains for: "+p); Set<List<OWLObjectPropertyExpression>> chains = new HashSet<List<OWLObjectPropertyExpression>>(); for (OWLSubPropertyChainOfAxiom spca : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) { if (spca.getSuperProperty().equals(p)) { List<OWLObjectPropertyExpression> chain = spca.getPropertyChain(); chains.add(chain); // note: limited form of cycle checking if (!chain.contains(p)) { chains.addAll(expandPropertyChain(chain)); } } } LOG.info(p+" ==> "+chains); return chains; }
private Map<OWLObjectProperty,Set<List<OWLObjectProperty>>> getPropertyChainMap() { if (pcMap == null) { pcMap = new HashMap<OWLObjectProperty,Set<List<OWLObjectProperty>>>(); for (OWLSubPropertyChainOfAxiom a : sourceOntology.getAxioms(AxiomType.SUB_PROPERTY_CHAIN_OF)) { //LOG.info("CHAIN:"+a+" // "+a.getPropertyChain().size()); if (a.getPropertyChain().size() == 2) { OWLObjectPropertyExpression p1 = a.getPropertyChain().get(0); OWLObjectPropertyExpression p2 = a.getPropertyChain().get(1); //LOG.info(" xxCHAIN:"+p1+" o "+p2); if (p1 instanceof OWLObjectProperty && p2 instanceof OWLObjectProperty) { List<OWLObjectProperty> list = new Vector<OWLObjectProperty>(); list.add((OWLObjectProperty) p2); list.add((OWLObjectProperty) a.getSuperProperty()); if (!pcMap.containsKey(p1)) pcMap.put((OWLObjectProperty) p1, new HashSet<List<OWLObjectProperty>>()); pcMap.get((OWLObjectProperty) p1).add(list); //LOG.info(" xxxCHAIN:"+p1+" ... "+list); } } else { // TODO } } } return pcMap; }
public void visit(OWLSubPropertyChainOfAxiom axiom) { List<OWLObjectPropertyExpression> subPropertyChain=axiom.getPropertyChain(); if (!containsBottomObjectProperty(subPropertyChain) && !axiom.getSuperProperty().isOWLTopObjectProperty()) { OWLObjectPropertyExpression superObjectPropertyExpression=axiom.getSuperProperty(); if (subPropertyChain.size()==1) { addInclusion(subPropertyChain.get(0),superObjectPropertyExpression); } else if (subPropertyChain.size()==2 && subPropertyChain.get(0).equals(superObjectPropertyExpression) && subPropertyChain.get(1).equals(superObjectPropertyExpression)) makeTransitive(axiom.getSuperProperty()); else if (subPropertyChain.size()==0) throw new IllegalArgumentException("Error: In OWL 2 DL, an empty property chain in property chain axioms is not allowd, but the ontology contains an axiom that the empty chain is a subproperty of "+superObjectPropertyExpression+"."); else { OWLObjectPropertyExpression[] subObjectProperties=new OWLObjectPropertyExpression[subPropertyChain.size()]; subPropertyChain.toArray(subObjectProperties); addInclusion(subObjectProperties,superObjectPropertyExpression); } } for (OWLObjectPropertyExpression objectPropertyExpression : subPropertyChain) { m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(objectPropertyExpression.getNamedProperty()); } m_axioms.m_objectPropertiesOccurringInOWLAxioms.add(axiom.getSuperProperty().getNamedProperty()); }
@Override public void visit(OWLSubPropertyChainOfAxiom axiom) { VarGenerator varGenerator = new VarGenerator(); List<OWLObjectPropertyExpression> propertyChain = axiom.getPropertyChain(); String subjectVar = this.subjectVar; for (int i = 0; i < propertyChain.size() - 1; i++) { OWLObjectPropertyExpression propertyExpression = propertyChain.get(i); // new object var will be created String objectVar = varGenerator.newVar(); sparql += subjectVar + render(propertyExpression) + objectVar + " ."; // subject var becomes old object var subjectVar = objectVar; } sparql += subjectVar + render(propertyChain.get(propertyChain.size()-1)) + this.objectVar + " ."; OWLObjectPropertyExpression superProperty = axiom.getSuperProperty(); sparql += this.subjectVar + render(superProperty) + objectVar; }
private Axiom transformOWLSubPropertyChainOfAxiom(OWLSubPropertyChainOfAxiom a) { List<OWLObjectPropertyExpression> sub = a.getPropertyChain(); OWLObjectPropertyExpression sup = a.getSuperProperty(); int size = sub.size(); Role[] lhss = new Role[size]; for (int i = 0; i < size; i++) { lhss[i] = new NamedRole(sub.get(i).asOWLObjectProperty().toStringID()); } Role rhs = new NamedRole(sup.asOWLObjectProperty().toStringID()); if (lhss.length == 1 || lhss.length == 2) { return new RoleInclusion(lhss, rhs); } else { problems.add("Unable to import axiom "+a.toString()+". RoleChains longer than 2 not supported."); return null; } }
protected static boolean isUnsupportedExtensionAxiom(OWLAxiom axiom) { return axiom instanceof OWLSubObjectPropertyOfAxiom || axiom instanceof OWLTransitiveObjectPropertyAxiom || axiom instanceof OWLSubPropertyChainOfAxiom || axiom instanceof OWLFunctionalObjectPropertyAxiom || axiom instanceof OWLInverseFunctionalObjectPropertyAxiom || axiom instanceof SWRLRule; }
@Override public T visit(OWLSubPropertyChainOfAxiom axiom) { throw new IllegalArgumentException( OWLSubPropertyChainOfAxiom.class.getSimpleName() + " cannot be converted to " + getTargetClass().getSimpleName()); }
private void tr(OWLSubPropertyChainOfAxiom ax) { List<OWLObjectPropertyExpression> chain = new ArrayList<OWLObjectPropertyExpression>(); for (OWLObjectPropertyExpression p : ax.getPropertyChain()) { chain.add(trTypeLevel(p)); } add(getOWLDataFactory().getOWLSubPropertyChainOfAxiom(chain, trTypeLevel(ax.getSuperProperty()))); }
public void visit(OWLSubPropertyChainOfAxiom arg0) { // TODO Auto-generated method stub String superPropertyName = null; OWLObjectPropertyExpression superPropertyExpression = arg0.getSuperProperty(); int counter = 1; writer.print("icons :-"); for (OWLObjectPropertyExpression subPropertyExpression : arg0.getPropertyChain()) { int firstCounter = counter; int secondCounter = ++counter; String subPropertyName = null; if (subPropertyExpression instanceof OWLObjectInverseOf) { int temp = firstCounter; firstCounter = secondCounter; secondCounter = temp; subPropertyName = mapper.getPredicateName(((OWLObjectInverseOf) subPropertyExpression).getInverse().asOWLObjectProperty()); } else { subPropertyName = mapper.getPredicateName(subPropertyExpression.asOWLObjectProperty()); } writer.print(String.format("%s(X%d,X%d),", subPropertyName, firstCounter, secondCounter)); } if (superPropertyExpression instanceof OWLObjectInverseOf) { superPropertyName = mapper.getPredicateName(((OWLObjectInverseOf) superPropertyExpression).getInverse().asOWLObjectProperty()); writer.print(String.format("not %s(X%d,X%d).", superPropertyName, counter, 1)); } else { superPropertyName = mapper.getPredicateName(arg0.getSuperProperty().asOWLObjectProperty()); writer.print(String.format("not %s(X%d,X%d).", superPropertyName, 1, counter)); } }
public void visit(OWLSubPropertyChainOfAxiom arg0) { // TODO Auto-generated method stub String superPropertyName = null; OWLObjectPropertyExpression superPropertyExpression = arg0.getSuperProperty(); int counter = 1; writer.print(":-"); for (OWLObjectPropertyExpression subPropertyExpression : arg0.getPropertyChain()) { int firstCounter = counter; int secondCounter = ++counter; String subPropertyName = null; if (subPropertyExpression instanceof OWLObjectInverseOf) { int temp = firstCounter; firstCounter = secondCounter; secondCounter = temp; subPropertyName = mapper.getPredicateName(((OWLObjectInverseOf) subPropertyExpression).getInverse().asOWLObjectProperty()); } else { subPropertyName = mapper.getPredicateName(subPropertyExpression.asOWLObjectProperty()); } writer.print(String.format("%s(X%d,X%d),", subPropertyName, firstCounter, secondCounter)); } if (superPropertyExpression instanceof OWLObjectInverseOf) { superPropertyName = mapper.getPredicateName(((OWLObjectInverseOf) superPropertyExpression).getInverse().asOWLObjectProperty()); writer.print(String.format("not %s(X%d,X%d).", superPropertyName, counter, 1)); } else { superPropertyName = mapper.getPredicateName(arg0.getSuperProperty().asOWLObjectProperty()); writer.print(String.format("not %s(X%d,X%d).", superPropertyName, 1, counter)); } }
@Override public Set<ComplexIntegerAxiom> visit(OWLSubPropertyChainOfAxiom axiom) throws TranslationException { Objects.requireNonNull(axiom); List<OWLObjectPropertyExpression> propChain = axiom.getPropertyChain(); OWLObjectPropertyExpression superProperty = axiom.getSuperProperty(); List<IntegerObjectPropertyExpression> chain = new ArrayList<>(); propChain.forEach(property -> chain.add(translateObjectPropertyExpression(property))); ComplexIntegerAxiom ret = getAxiomFactory().createSubPropertyChainOfAxiom(chain, translateObjectPropertyExpression(superProperty), translateAnnotations(axiom.getAnnotations())); return Collections.singleton(ret); }
@Override public Void visit(OWLSubPropertyChainOfAxiom axiom) { long chain = getOrCreateNode(getIri(axiom.getSuperProperty())); int i = 0; for (OWLObjectPropertyExpression property : axiom.getPropertyChain()) { long link = getOrCreateNode(getIri(property)); long relationship = getOrCreateRelationship(chain, link, OwlRelationships.OWL_PROPERTY_CHAIN_AXIOM); graph.setRelationshipProperty(relationship, "order", i++); } return null; }
@Override public void visit(OWLSubPropertyChainOfAxiom axiom) { hashCode = primes[24]; hashCode = hashCode * MULT + axiom.getPropertyChain().hashCode(); hashCode = hashCode * MULT + axiom.getSuperProperty().hashCode(); hashCode = hashCode * MULT + axiom.getAnnotations().hashCode(); }
@Override public OWLSubPropertyChainOfAxiom getAxiomWithoutAnnotations() { if (!isAnnotated()) { return this; } return new OWLSubPropertyChainAxiomImpl(getPropertyChain(), getSuperProperty(), NO_ANNOTATIONS); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!super.equals(obj)) { return false; } if (!(obj instanceof OWLSubPropertyChainOfAxiom)) { return false; } OWLSubPropertyChainOfAxiom other = (OWLSubPropertyChainOfAxiom) obj; return other.getPropertyChain().equals(getPropertyChain()) && other.getSuperProperty().equals(superProperty); }
@Override public void visit(@Nonnull OWLSubPropertyChainOfAxiom axiom) { for (OWLObjectPropertyExpression prop : axiom.getPropertyChain()) { prop.accept(this); } axiom.getSuperProperty().accept(this); processAxiomAnnotations(axiom); }
public static String formatAxiom(OWLAxiom a, OWLOntology ont) { if (a instanceof OWLSubPropertyChainOfAxiom) { // TODO: implement return a.toString(); } else if (a instanceof OWLSubObjectPropertyOfAxiom) { // TODO: implement return a.toString(); } else if (a instanceof OWLSubClassOfAxiom) { OWLSubClassOfAxiom sc = (OWLSubClassOfAxiom) a; return formatClassExpression(sc.getSubClass(), ont) + " \u2286 " + formatClassExpression(sc.getSuperClass(), ont); } else if (a instanceof OWLEquivalentClassesAxiom) { OWLEquivalentClassesAxiom ec = (OWLEquivalentClassesAxiom) a; List<OWLClassExpression> ces = ec.getClassExpressionsAsList(); StringBuilder sb = new StringBuilder(); sb.append(formatClassExpression(ces.get(0), ont)); for (int i = 1; i < ces.size(); i++) { sb.append(" = "); sb.append(formatClassExpression(ces.get(i), ont)); } return sb.toString(); } else if (a instanceof OWLDeclarationAxiom) { OWLDeclarationAxiom da = (OWLDeclarationAxiom) a; OWLEntity ent = da.getEntity(); String name = (ent.isOWLClass()) ? getLabel(ent.asOWLClass(), ont) : ent.toString(); return "init(" + name + ")"; } else { return a.toString(); } }
public Object visit(OWLSubPropertyChainOfAxiom axiom) { Set<OWLObjectPropertyRangeAxiom> rangeAxioms = getCurrentOntology().getAxioms(AxiomType.OBJECT_PROPERTY_RANGE, true); if (rangeAxioms.isEmpty()) { return false; } // Do we have a range restriction imposed on our super property? for (OWLObjectPropertyRangeAxiom rngAx : rangeAxioms) { if (getPropertyManager().isSubPropertyOf(axiom.getSuperProperty(), rngAx.getProperty())) { // Imposed range restriction! OWLClassExpression imposedRange = rngAx.getRange(); // There must be an axiom that imposes a range on the last prop in the chain List<OWLObjectPropertyExpression> chain = axiom.getPropertyChain(); if (!chain.isEmpty()) { OWLObjectPropertyExpression lastProperty = chain.get(chain.size() - 1); boolean rngPresent = false; for (OWLOntology ont : getCurrentOntology().getImportsClosure()) { for (OWLObjectPropertyRangeAxiom lastPropRngAx : ont.getObjectPropertyRangeAxioms(lastProperty)) { if (lastPropRngAx.getRange().equals(imposedRange)) { // We're o.k. rngPresent = true; break; } } } if (!rngPresent) { profileViolations.add(new LastPropertyInChainNotInImposedRange(getCurrentOntology(), axiom, rngAx)); } } } } return null; }
@Override protected void writeAxiom(OWLSubPropertyChainOfAxiom axiom, BinaryOWLOutputStream outputStream) throws IOException { // Must be a list List<OWLObjectPropertyExpression> propertyChain = axiom.getPropertyChain(); outputStream.writeInt(propertyChain.size()); for(OWLObjectPropertyExpression propertyExpression : propertyChain) { outputStream.writeOWLObject(propertyExpression); } outputStream.writeOWLObject(axiom.getSuperProperty()); }
@Override protected OWLSubPropertyChainOfAxiom readAxiom(BinaryOWLInputStream inputStream, Set<OWLAnnotation> annotations) throws IOException, BinaryOWLParseException { int size = inputStream.readInt(); List<OWLObjectPropertyExpression> chain = new ArrayList<OWLObjectPropertyExpression>(size); for(int i = 0; i < size; i++) { OWLObjectPropertyExpression property = inputStream.readOWLObject(); chain.add(property); } OWLObjectPropertyExpression superProperty = inputStream.readOWLObject(); return inputStream.getDataFactory().getOWLSubPropertyChainOfAxiom(chain, superProperty, annotations); }
/** * Log property chain. * * @param prop the prop * @param ontology the ontology */ public static void logPropertyChain(OWLSubPropertyChainOfAxiom prop, OWLOntology ontology) { Logger.getLogger(OwlUtility.class).info(" property chain = " + prop); Logger.getLogger(OwlUtility.class).debug( " chain = " + prop.getPropertyChain()); Logger.getLogger(OwlUtility.class).debug( " super property = " + prop.getSuperProperty()); Logger.getLogger(OwlUtility.class).debug( " signature = " + prop.getSignature()); Logger.getLogger(OwlUtility.class).debug( " entity type = " + prop.getAxiomType()); // Only works in OWLAPI 4 // Logger.getLogger(OwlUtility.class).debug( // " annotation properties in signature = " // + prop.getAnnotationPropertiesInSignature().size()); // for (final OWLAnnotationProperty aprop : prop // .getAnnotationPropertiesInSignature()) { // Logger.getLogger(OwlUtility.class).debug(" annotation = " + aprop); // } Logger.getLogger(OwlUtility.class).debug( " classes in signature = " + prop.getClassesInSignature().size()); for (final OWLClass owlClass : prop.getClassesInSignature()) { Logger.getLogger(OwlUtility.class).debug(" class = " + owlClass); } Logger.getLogger(OwlUtility.class).debug( " data properties in signature = " + prop.getDataPropertiesInSignature().size()); for (final OWLDataProperty dprop : prop.getDataPropertiesInSignature()) { Logger.getLogger(OwlUtility.class) .debug(" data property = " + dprop); } Logger.getLogger(OwlUtility.class) .debug( " datatypes in signature = " + prop.getDatatypesInSignature().size()); for (final OWLDatatype dtype : prop.getDatatypesInSignature()) { Logger.getLogger(OwlUtility.class).debug(" datatype = " + dtype); } Logger.getLogger(OwlUtility.class).debug( " nested class expressions = " + prop.getNestedClassExpressions().size()); for (final OWLClassExpression expr : prop.getNestedClassExpressions()) { Logger.getLogger(OwlUtility.class).debug(" expr = " + expr); } Logger.getLogger(OwlUtility.class).debug( " object properties in signature = " + prop.getObjectPropertiesInSignature().size()); for (final OWLObjectProperty oprop : prop.getObjectPropertiesInSignature()) { Logger.getLogger(OwlUtility.class).debug(" property = " + oprop); } // loaded from ontology - n/a }
public void visit(OWLSubPropertyChainOfAxiom axiom) { notSupported(axiom); }
public Boolean visit(OWLSubPropertyChainOfAxiom axiom) { return reasoner.isSubObjectPropertyExpressionOf(axiom.getPropertyChain(),axiom.getSuperProperty()); }
public void visit(OWLSubPropertyChainOfAxiom axiom) { }
@SuppressWarnings("static-method") public ElkObjectPropertyChain convert( OWLSubPropertyChainOfAxiom owlSubPropertyChainOfAxiom) { return new ElkObjectPropertyChainWrap<List<? extends OWLObjectPropertyExpression>>( owlSubPropertyChainOfAxiom.getPropertyChain()); }
@Override public ElkAxiom visit(OWLSubPropertyChainOfAxiom owlSubPropertyChainOfAxiom) { return new ElkSubObjectPropertyChainOfAxiomWrap<OWLSubPropertyChainOfAxiom>( owlSubPropertyChainOfAxiom); }
@Override public ElkObjectPropertyAxiom visit( OWLSubPropertyChainOfAxiom owlSubPropertyChainOfAxiom) { return new ElkSubObjectPropertyChainOfAxiomWrap<OWLSubPropertyChainOfAxiom>( owlSubPropertyChainOfAxiom); }
@Override public void visit(OWLSubPropertyChainOfAxiom axiom) { defaultVisit(axiom); }
@Override public OWLAxiom visit(OWLSubPropertyChainOfAxiom axiom) { return factory.getOWLSubPropertyChainOfAxiom(axiom.getPropertyChain(), axiom.getSuperProperty(), annotations); }
@Override public void visit(OWLSubPropertyChainOfAxiom axiom) { }
@Override public Boolean visit(OWLSubPropertyChainOfAxiom axiom) { return true; }
@Override public Boolean visit(OWLSubPropertyChainOfAxiom axiom) { return false; }
@Override public Boolean visit(OWLSubPropertyChainOfAxiom axiom) { Objects.requireNonNull(axiom); return add(this.df.getOWLSubPropertyChainOfAxiom(axiom.getPropertyChain(), axiom.getSuperProperty(), reg(axiom.getAnnotations()))); }
@Override public Boolean visit(OWLSubPropertyChainOfAxiom axiom) { Objects.requireNonNull(axiom); return add(this.df.getOWLSubPropertyChainOfAxiom(axiom.getPropertyChain(), axiom.getSuperProperty(), empty())); }