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

项目:owl2diagram    文件:ObjectPropertyRestriction.java   
private static <F extends OWLPropertyRange> OWLClass getTarget(OWLQuantifiedRestriction<?,?,F> ex) throws RendererException {
    if(ex.getFiller() instanceof OWLClass) {
        return (OWLClass)ex.getFiller();
    }
    else {
        throw new RendererException("Filler of class expression not a simple unary OWL class: " + ex);
    }
}
项目:owlapi-gwt    文件:OWLQuantifiedRestrictionImpl.java   
@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!super.equals(obj)) {
        return false;
    }
    if (!(obj instanceof OWLQuantifiedRestriction)) {
        return false;
    }
    return ((OWLQuantifiedRestriction<?>) obj).getFiller().equals(filler);
}
项目:owltools    文件:DescriptionTreeSimilarity.java   
/**
 * makes a reduced union expression.
 * 
 * Uses the following two reduction rules:
 * 
 * (r1 some X) U (r2 some Y) ==> lcs(r1,r2) some MakeUnionOf(X,Y)
 * (r1 some X) U X ==> reflexive-version-of-r1 some X
 * 
 * TODO: test for (r some r some X) u (r some X) cases. needs to be done over final expression.
 *  
 * if a reduced form cannot be made, returns null
 * 
 * @param xa
 * @param xb
 * @return class expression
 */
private OWLClassExpression makeUnionUsingReflexiveProperty(OWLClassExpression xa, OWLClassExpression xb) {
    LOG.info("testing if there is a more compact union expression for "+xa+" ++ "+xb);
    OWLDataFactory df = graph.getDataFactory();
    if (xa instanceof OWLQuantifiedRestriction) {
        // TODO - check before casting
        OWLObjectProperty prop = (OWLObjectProperty) ((OWLQuantifiedRestriction) xa).getProperty();
        OWLClassExpression xaRest = (OWLClassExpression) ((OWLQuantifiedRestriction)xa).getFiller();
        if (xb instanceof OWLQuantifiedRestriction) {
            OWLObjectPropertyExpression p2 =
                propertySubsumer(prop, 
                    ((OWLQuantifiedObjectRestriction) xb).getProperty());

            if (p2 != null) {
                OWLClassExpression xbRest = (OWLClassExpression) ((OWLQuantifiedRestriction)xb).getFiller();
                OWLClassExpression x = makeUnionWithReduction(xaRest,xbRest);
                // todo - mixing some and all
                if (xa instanceof OWLObjectSomeValuesFrom)
                    return df.getOWLObjectSomeValuesFrom(p2,x);
                else if (xa instanceof OWLObjectAllValuesFrom)
                    return df.getOWLObjectAllValuesFrom(p2, x);
            }
        }
        LOG.info("  test: "+xaRest+" == "+xb);


        if (xaRest.equals(xb)) {
            LOG.info("     TRUE: "+xaRest+" == "+xb);

            OWLObjectProperty rprop = null;
            if (graph.getIsReflexive(prop)) {
                rprop = prop;
            }
            if (forceReflexivePropertyCreation) {
                OWLOntologyManager manager = graph.getManager();
                OWLOntology ont = graph.getSourceOntology();
                rprop = 
                    df.getOWLObjectProperty(IRI.create(prop.getIRI().toString()+"_reflexive"));
                manager.applyChange(new AddAxiom(ont, df.getOWLSubObjectPropertyOfAxiom(prop, rprop)));
                manager.applyChange(new AddAxiom(ont, df.getOWLTransitiveObjectPropertyAxiom(rprop)));
                LOG.info("  reflexive prop:"+rprop);

            }
            if (rprop != null) {
                if (xa instanceof OWLObjectSomeValuesFrom)
                    return df.getOWLObjectSomeValuesFrom(rprop,xb);
                else if (xa instanceof OWLObjectAllValuesFrom)
                    return df.getOWLObjectAllValuesFrom(rprop, xb);
            }

        }
    }
    return null;
}