Java 类org.semanticweb.owlapi.model.OWLSubPropertyAxiom 实例源码

项目:semantika    文件:OwlPropertyStructureHandler.java   
private void addSubPropertyAxiom(OWLSubPropertyAxiom<?> axiom)
{
   OWLPropertyExpression<?,?> subProperty = axiom.getSubProperty();
   OWLPropertyExpression<?,?> superProperty = axiom.getSuperProperty();

   OwlNode<OWLPropertyExpression<?,?>> subClassNode = createNode(subProperty);
   OwlNode<OWLPropertyExpression<?,?>> superClassNode = createNode(superProperty);

   if (mPropertyCache.contains(subProperty)) {
      subClassNode = findNode(subProperty);
      superClassNode.setParent(subClassNode.getParent());
      subClassNode.setParent(superClassNode);
   }
   else if (mPropertyCache.contains(superProperty)) {
      superClassNode = findNode(superProperty);
      subClassNode.setParent(superClassNode);
   }
   else {
      superClassNode.setParent(mRoot);
      subClassNode.setParent(superClassNode);
   }
   mPropertyCache.add(subProperty);
   mPropertyCache.add(superProperty);
}
项目:owltools    文件:OwlHelper.java   
public static Set<OWLObjectPropertyExpression> getSuperProperties(OWLObjectPropertyExpression prop, OWLOntology ont) {
    Set<OWLObjectPropertyExpression> result = new HashSet<>();
    Set<OWLSubObjectPropertyOfAxiom> axioms = ont.getObjectSubPropertyAxiomsForSubProperty(prop);
    for (OWLSubPropertyAxiom<OWLObjectPropertyExpression> axiom : axioms) {
        result.add(axiom.getSuperProperty());
    }
    return result;
}
项目:semantika    文件:TMappingProcessor.java   
/**
 * A utility method to process OWL <code>SubDataPropertyOf(DPE1 DPE2)</code> axiom and produce
 * inferred mapping assertions.
 */
@Override
public void visit(OWLSubDataPropertyOfAxiom axiom)
{
   /*
    * Trace all the ancestors of the data property expression in the given OWL SubDataPropertyOf axiom.
    */
   Set<OWLSubPropertyAxiom<?>> ancestors = mOntology.traceAncestors(axiom.getSubProperty(), true);
   for (OWLSubPropertyAxiom<?> ax : ancestors) {
      /*
       * Get all (copy) known mappings for the visited sub data property expression.
       */
      OWLDataPropertyExpression subProperty = (OWLDataPropertyExpression) ax.getSubProperty();
      subProperty.accept(this); // this call will produce (sub property) mSignature
      Set<IMapping> subPropertyMappings = getMappingsForPropertyExpression();
      if (subPropertyMappings.isEmpty()) {
         continue;
      }
      /*
       * Produce the "extra" mappings for the visited super data property expression as many as
       * the known mappings in the sub data property expression.
       */
      OWLDataPropertyExpression superProperty = (OWLDataPropertyExpression) ax.getSuperProperty();
      superProperty.accept(this); // this call will produce (super property) mSignature and mIsInverse
      URI superPropertySignature = mSignature;
      for (IMapping subPropertyMapping : subPropertyMappings) {
         IPropertyMapping pm = createPropertyMapping(superPropertySignature, subPropertyMapping, mIsInverse);
         addInferredMapping(pm);
      }
   }
}
项目:semantika    文件:TMappingProcessor.java   
/**
 * A utility method to process OWL <code>SubObjectPropertyOf(OPE1 OPE2)</code> axiom and produce
 * inferred mapping assertions.
 */
@Override
public void visit(OWLSubObjectPropertyOfAxiom axiom)
{
   /*
    * Trace all the ancestors of the object property expression in the given OWL SubObjectPropertyOf axiom.
    */
   Set<OWLSubPropertyAxiom<?>> ancestors = mOntology.traceAncestors(axiom.getSubProperty(), true);
   for (OWLSubPropertyAxiom<?> ax : ancestors) {
      /*
       * Get all (copy) known mappings for the visited sub object property expression.
       */
      OWLObjectPropertyExpression subProperty = (OWLObjectPropertyExpression) ax.getSubProperty();
      subProperty.accept(this); // this call will produce (sub property) mSignature
      Set<IMapping> subPropertyMappings = getMappingsForPropertyExpression();
      if (subPropertyMappings.isEmpty()) {
         continue;
      }
      /*
       * Produce the "extra" mappings for the visited super object property expression as many as
       * the known mappings in the sub object property expression.
       */
      OWLObjectPropertyExpression superProperty = (OWLObjectPropertyExpression) ax.getSuperProperty();
      superProperty.accept(this); // this call will produce (super property) mSignature and mIsInverse
      URI superPropertySignature = mSignature;
      for (IMapping subPropertyMapping : subPropertyMappings) {
         IPropertyMapping pm = createPropertyMapping(superPropertySignature, subPropertyMapping, mIsInverse);
         addInferredMapping(pm);
      }
   }
}
项目:owlapi-gwt    文件:OWLSubPropertyAxiomImpl.java   
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!super.equals(obj)) {
        return false;
    }
    if (!(obj instanceof OWLSubPropertyAxiom)) {
        return false;
    }
    OWLSubPropertyAxiom<?> other = (OWLSubPropertyAxiom<?>) obj;
    return other.getSubProperty().equals(subProperty)
            && other.getSuperProperty().equals(superProperty);
}
项目:owlapi-gwt    文件:OWLSubPropertyAxiomImpl.java   
@Override
protected int compareObjectOfSameType(OWLObject object) {
    OWLSubPropertyAxiom<?> other = (OWLSubPropertyAxiom<?>) object;
    int diff = subProperty.compareTo(other.getSubProperty());
    if (diff != 0) {
        return diff;
    }
    return superProperty.compareTo(other.getSuperProperty());
}
项目:Widoco    文件:OntologyDifferencesRenderer.java   
private static String axiomSetToHTML(Set<Object> set, boolean isAddition, Properties lang){
    String v = "";
    String message;
    if(isAddition){
        message=lang.getProperty(Constants.LANG_ADDED)+": ";
    }else{
        message=lang.getProperty(Constants.LANG_DELETED)+": ";
    }
    for(Object f:set){
        try{
            v+="<li>";
            if(f instanceof OWLSubClassOfAxiom){
                v+=message+lang.getProperty(Constants.LANG_SUBCLASS_OF) +" "+ ((OWLSubClassOfAxiom)f).getSuperClass().asOWLClass().getIRI();
            }else if(f instanceof OWLSubPropertyAxiom){
                OWLPropertyExpression prop = ((OWLSubPropertyAxiom)f).getSuperProperty();
                if(prop instanceof OWLObjectPropertyImpl){
                    v+=message+lang.getProperty(Constants.LANG_SUBPROP_OF) +" "+ ((OWLObjectPropertyImpl)prop).getIRI();
                }else if(prop instanceof OWLDataPropertyImpl){
                    v+=message+lang.getProperty(Constants.LANG_SUBPROP_OF) +" "+ ((OWLDataPropertyImpl)prop).getIRI();
                }
            }else if(f instanceof OWLObjectPropertyDomainAxiom){
                v+=message+Constants.LANG_DOMAIN+" "+expressionToHTML(((OWLObjectPropertyDomainAxiom)f).getDomain(), lang);
            }else if(f instanceof OWLDataPropertyDomainAxiom){
                v+=message+lang.getProperty(Constants.LANG_DOMAIN)+" "+expressionToHTML(((OWLDataPropertyDomainAxiom)f).getDomain(), lang);
            }else if(f instanceof OWLObjectPropertyRangeAxiom){
                v+=message+lang.getProperty(Constants.LANG_RANGE)+" "+expressionToHTML(((OWLObjectPropertyRangeAxiom)f).getRange(), lang);
            }else if(f instanceof OWLDataPropertyRangeAxiom){
                v+=message+lang.getProperty(Constants.LANG_RANGE)+" "+((OWLDataPropertyRangeAxiom)f).getRange().asOWLDatatype().getIRI();
            }else if(f instanceof OWLAnnotationAssertionAxiom){
                v+= message+((OWLAnnotationAssertionAxiom)f).getProperty().toString() +" "+ ((OWLAnnotationAssertionAxiom)f).getValue().toString();
            }else{
                //other less typical axioms
                v+=message+((OWLAxiom)f).getAxiomType().getName()+" "+f.toString().replace("<", "&lt;").replace(">", "&gt;");
            }
            /**
             * To add if we want to refine
             * OWLDisjointClassesAxiom, OWLDisjointDataPropertiesAxiom, OWLDisjointObjectPropertiesAxiom,
             * OWLEquivalentClassesAxiom, OWLEquivalentDataPropertiesAxiom, OWLEquivalentObjectPropertiesAxiom, 
             * OWLFunctionalDataPropertyAxiom, OWLFunctionalObjectPropertyAxiom,
             */
            v+="</li>\n";
        }catch (Exception e){
            System.out.println("Error while transforming "+f.toString() +" "+e.getMessage());
        }

    }

    return v;
}