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

项目:Hermit_1.3.8_android    文件:OWLAxioms.java   
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>();
}
项目:owltools    文件:Mooncat.java   
private static Set<OWLObjectPropertyExpression> getSuperObjectProperties(OWLObjectPropertyExpression p, OWLReasoner reasoner, OWLOntology ont) {
    if (reasoner != null) {
        return reasoner.getSuperObjectProperties(p, false).getFlattened();
    }
    // Elk does not support this (sigh), so we do it ourselves
       Set<OWLObjectPropertyExpression> sups = new HashSet<>();
       Stack<OWLObjectPropertyExpression> seeds = new Stack<>();
       seeds.add(p);
    while (seeds.size() > 0) {
        OWLObjectPropertyExpression nextp = seeds.pop();
        Set<OWLObjectPropertyExpression> xset = 
                ont.getObjectSubPropertyAxiomsForSubProperty(nextp).stream().
                map(a -> a.getSuperProperty()).collect(Collectors.toSet());

        seeds.addAll(xset);
        seeds.removeAll(sups);
        sups.addAll(xset);       
    }
    return sups;
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
protected Node<OWLObjectPropertyExpression> objectPropertyHierarchyNodeToNode(
        HierarchyNode<Role> hierarchyNode) {
    Set<OWLObjectPropertyExpression> result = new HashSet<OWLObjectPropertyExpression>();
    OWLDataFactory factory = getDataFactory();
    for (Role role : hierarchyNode.getEquivalentElements()) {
        if (role instanceof AtomicRole)
            result.add(factory.getOWLObjectProperty(IRI
                    .create(((AtomicRole) role).getIRI())));
        else {
            OWLObjectPropertyExpression ope = factory
                    .getOWLObjectProperty(IRI.create(((InverseRole) role)
                            .getInverseOf().getIRI()));
            result.add(factory.getOWLObjectInverseOf(ope));
        }
    }
    return new OWLObjectPropertyNode(result);
}
项目:Hermit_1.3.8_android    文件:ObjectPropertyInclusionManager.java   
protected Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> findEquivalentProperties(Collection<OWLObjectPropertyExpression[]> simpleObjectPropertyInclusions) {
    Graph<OWLObjectPropertyExpression> propertyDependencyGraph=new Graph<OWLObjectPropertyExpression>();
    Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> equivalentObjectPropertiesMapping=new HashMap<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>>();
    for (OWLObjectPropertyExpression[] inclusion : simpleObjectPropertyInclusions)
        if (!inclusion[0].equals(inclusion[1]) && !inclusion[0].equals(inclusion[1].getInverseProperty().getSimplified()))
            propertyDependencyGraph.addEdge(inclusion[0],inclusion[1]);
    propertyDependencyGraph.transitivelyClose();
    for (OWLObjectPropertyExpression objExpr : propertyDependencyGraph.getElements()) {
        if (propertyDependencyGraph.getSuccessors(objExpr).contains(objExpr) || propertyDependencyGraph.getSuccessors(objExpr).contains(objExpr.getInverseProperty().getSimplified())) {
            Set<OWLObjectPropertyExpression> equivPropertiesSet=new HashSet<OWLObjectPropertyExpression>();
            for (OWLObjectPropertyExpression succ : propertyDependencyGraph.getSuccessors(objExpr)) {
                if (!succ.equals(objExpr) && (propertyDependencyGraph.getSuccessors(succ).contains(objExpr) || propertyDependencyGraph.getSuccessors(succ).contains(objExpr.getInverseProperty().getSimplified())))
                    equivPropertiesSet.add(succ);
            }
            equivalentObjectPropertiesMapping.put(objExpr,equivPropertiesSet);
        }
    }
    return equivalentObjectPropertiesMapping;
}
项目:owltools    文件:OWLInAboxTranslator.java   
/**
 * @param p
 * @return type-level form of relation
 */
private OWLObjectPropertyExpression trTypeLevel(
        OWLObjectPropertyExpression p) {
    if (!this.isTranslateObjectProperty) {
        return p;
    }
    if (p instanceof OWLObjectInverseOf) {
        OWLObjectPropertyExpression p2 = trTypeLevel(((OWLObjectInverseOf)p).getInverse());
        return getOWLDataFactory().getOWLObjectInverseOf(p2);
    }
    else {
        instanceLevelRelations.add((OWLObjectProperty)p);
        IRI iri = ((OWLObjectProperty) p).getIRI();
        return trTypeLevel(iri);
    }
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
protected boolean isAsymmetric(
        OWLObjectPropertyExpression propertyExpression) {
    checkPreConditions(propertyExpression);
    if (!m_isConsistent)
        return true;
    OWLDataFactory factory = getDataFactory();
    OWLIndividual freshIndividualA = factory
            .getOWLAnonymousIndividual("fresh-individual-A");
    OWLIndividual freshIndividualB = factory
            .getOWLAnonymousIndividual("fresh-individual-B");
    OWLAxiom assertion1 = factory.getOWLObjectPropertyAssertionAxiom(
            propertyExpression, freshIndividualA, freshIndividualB);
    OWLAxiom assertion2 = factory.getOWLObjectPropertyAssertionAxiom(
            propertyExpression.getInverseProperty(), freshIndividualA,
            freshIndividualB);
    Tableau tableau = getTableau(assertion1, assertion2);
    boolean result = tableau.isSatisfiable(true, null, null, null, null,
            null, new ReasoningTaskDescription(true, "asymmetry of {0}",
                    H(propertyExpression)));
    tableau.clearAdditionalDLOntology();
    return !result;
}
项目:HermiT-android    文件:Reasoner.java   
public NodeSet<OWLNamedIndividual> getObjectPropertyValues(
        OWLNamedIndividual namedIndividual,
        OWLObjectPropertyExpression propertyExpression) {
    checkPreConditions(namedIndividual, propertyExpression);
    if (!m_isConsistent) {
        Node<OWLNamedIndividual> node = new OWLNamedIndividualNode(
                getAllNamedIndividuals());
        return new OWLNamedIndividualNodeSet(Collections.singleton(node));
    }
    AtomicRole role = H(propertyExpression.getNamedProperty());
    if (!m_dlOntology.containsObjectRole(role))
        return new OWLNamedIndividualNodeSet();
    initialisePropertiesInstanceManager();
    Individual individual = H(namedIndividual);
    Set<Individual> result;
    if (propertyExpression.getSimplified().isAnonymous()) {
        // inverse role
        result = m_instanceManager.getObjectPropertySubjects(role,
                individual);
    } else {
        // named role
        result = m_instanceManager
                .getObjectPropertyValues(role, individual);
    }
    return sortBySameAsIfNecessary(result);
}
项目:HermiT-android    文件:Reasoner.java   
public boolean hasObjectPropertyRelationship(OWLNamedIndividual subject,
        OWLObjectPropertyExpression propertyExpression,
        OWLNamedIndividual object) {
    checkPreConditions(subject, propertyExpression, object);
    if (!m_isConsistent)
        return true;
    initialisePropertiesInstanceManager();
    OWLObjectProperty property = propertyExpression.getNamedProperty();
    if (propertyExpression.getSimplified().isAnonymous()) {
        OWLNamedIndividual tmp = subject;
        subject = object;
        object = tmp;
    }
    AtomicRole role = H(property);
    Individual subj = H(subject);
    Individual obj = H(object);
    return m_instanceManager.hasObjectRoleRelationship(role, subj, obj);
}
项目:HermiT-android    文件:Reasoner.java   
protected Node<OWLObjectPropertyExpression> objectPropertyHierarchyNodeToNode(
        HierarchyNode<Role> hierarchyNode) {
    Set<OWLObjectPropertyExpression> result = new HashSet<OWLObjectPropertyExpression>();
    OWLDataFactory factory = getDataFactory();
    for (Role role : hierarchyNode.getEquivalentElements()) {
        if (role instanceof AtomicRole)
            result.add(factory.getOWLObjectProperty(IRI
                    .create(((AtomicRole) role).getIRI())));
        else {
            OWLObjectPropertyExpression ope = factory
                    .getOWLObjectProperty(IRI.create(((InverseRole) role)
                            .getInverseOf().getIRI()));
            result.add(factory.getOWLObjectInverseOf(ope));
        }
    }
    return new OWLObjectPropertyNode(result);
}
项目:owltools    文件:OWLGraphWrapperEdgesExtendedTest.java   
/**
 * Test {@link OWLGraphWrapperEdgesExtended#getSubPropertyClosureOf(OWLObjectPropertyExpression)}.
 */
@Test
public void shouldGetSubPropertyClosureOf()
{
    OWLObjectProperty fakeRel1 = 
            wrapper.getOWLObjectPropertyByIdentifier("fake_rel1");
    List<OWLObjectProperty> expectedSubProps = new ArrayList<OWLObjectProperty>();
    expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel2"));
    expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel3"));
    expectedSubProps.add(wrapper.getOWLObjectPropertyByIdentifier("fake_rel4"));
    //fake_rel3 and fake_rel4 are sub-properties of fake_rel2, 
    //which is the sub-property of fake_rel1
    //we also test the order of the returned properties
    LinkedHashSet<OWLObjectPropertyExpression> subprops = 
            wrapper.getSubPropertyClosureOf(fakeRel1);
    assertEquals("Incorrect sub-properties returned: ", 
            expectedSubProps, new ArrayList<OWLObjectPropertyExpression>(subprops));

}
项目:HermiT-android    文件:OWLNormalization.java   
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());
}
项目:Hermit_1.3.8_android    文件:OWLNormalization.java   
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());
}
项目:Hermit_1.3.8_android    文件:ObjectPropertyInclusionManager.java   
protected void increaseWithDefinedInverseIfNecessary(OWLObjectPropertyExpression propertyToBuildAutomatonFor,Automaton leafPropertyAutomaton,Map<OWLObjectPropertyExpression,Set<OWLObjectPropertyExpression>> inversePropertiesMap,Map<OWLObjectPropertyExpression,Automaton> individualAutomata) {
    Set<OWLObjectPropertyExpression> inverses=inversePropertiesMap.get(propertyToBuildAutomatonFor);
    if (inverses!=null) {
        Automaton inversePropertyAutomaton=null;
        for (OWLObjectPropertyExpression inverse : inverses) {
            if (individualAutomata.containsKey(inverse) && !inverse.equals(propertyToBuildAutomatonFor)) {
                inversePropertyAutomaton=individualAutomata.get(inverse);
                increaseAutomatonWithInversePropertyAutomaton(leafPropertyAutomaton,inversePropertyAutomaton);
            }
        }
    }
    else if (individualAutomata.containsKey(propertyToBuildAutomatonFor.getInverseProperty().getSimplified())) {
        Automaton autoOfInv_Role = individualAutomata.get(propertyToBuildAutomatonFor.getInverseProperty().getSimplified());
        increaseAutomatonWithInversePropertyAutomaton(leafPropertyAutomaton,autoOfInv_Role);
    }
}
项目:HermiT-android    文件:OWLAxioms.java   
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>();
}
项目:HermiT-android    文件:OWLClausification.java   
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));
}
项目:HermiT-android    文件:ReducedABoxOnlyClausification.java   
protected Atom getRoleAtom(OWLObjectPropertyExpression objectProperty,Term first,Term second) {
    AtomicRole atomicRole;
    objectProperty=objectProperty.getSimplified();
    if (objectProperty.isAnonymous()) {
        OWLObjectProperty internalObjectProperty=objectProperty.getNamedProperty();
        atomicRole=AtomicRole.create(internalObjectProperty.getIRI().toString());
        Term tmp=first;
        first=second;
        second=tmp;
    }
    else
        atomicRole=AtomicRole.create(objectProperty.asOWLObjectProperty().getIRI().toString());
    if (m_allAtomicObjectRoles.contains(atomicRole))
        return Atom.create(atomicRole,first,second);
    else
        throw new IllegalArgumentException("Internal error: fresh properties in property assertions are not compatible with incremental ABox loading!");
}
项目:owltools    文件:OWLGraphWrapperEdges.java   
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;
}
项目:neo4j-sparql-extension-yars    文件:AbstractExtractor.java   
/**
 * Returns the URIs of a list of object properties.
 * 
 * @param properties object properties
 * @return list of URIs
 */
protected static List<String> getStrings(List<OWLObjectPropertyExpression> properties) {
    List<String> strs = new ArrayList<>();
    for (OWLObjectPropertyExpression op : properties) {
        strs.add(getString(op));
    }
    return strs;
}
项目:elk-reasoner    文件:ElkDisjointObjectPropertiesAxiomWrap.java   
@Override
public List<? extends ElkObjectPropertyExpression> getObjectPropertyExpressions() {
    List<ElkObjectPropertyExpression> result = new ArrayList<ElkObjectPropertyExpression>();
    for (OWLObjectPropertyExpression ope : this.owlObject.getProperties()) {
        result.add(converter.convert(ope));
    }
    return result;
}
项目:elk-reasoner    文件:ElkEquivalentObjectPropertiesAxiomWrap.java   
@Override
public List<? extends ElkObjectPropertyExpression> getObjectPropertyExpressions() {
    List<ElkObjectPropertyExpression> result = new ArrayList<ElkObjectPropertyExpression>();
    for (OWLObjectPropertyExpression ope : this.owlObject.getProperties()) {
        result.add(converter.convert(ope));
    }
    return result;
}
项目:owltools    文件:PropertyViewOntologyBuilder.java   
public OWLClassExpression expandPropertyChain(List<OWLObjectPropertyExpression> chain, OWLClassExpression t) {
    OWLClassExpression x = t;
    for (int i = chain.size()-1; i>=0;  i--) {
        x = this.owlDataFactory.getOWLObjectSomeValuesFrom(chain.get(i),t);
        t = x;
    }
    return x;
}
项目:minerva    文件:CoreMolecularModelManager.java   
void removeType(ModelContainer model,
        OWLIndividual i, 
        OWLObjectPropertyExpression p,
        OWLClassExpression filler,
        METADATA metadata) {
    OWLDataFactory f = model.getOWLDataFactory();
    OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(f.getOWLObjectSomeValuesFrom(p, filler), i);
    removeAxiom(model, axiom, metadata);
}
项目:owltools    文件:CompositionalClassPredictor.java   
private boolean getReachableOWLClasses(OWLClassExpression c, Set<OWLClassExpression> elts) {
    if (c instanceof OWLObjectIntersectionOf) {
        for (OWLClassExpression x : ((OWLObjectIntersectionOf)c).getOperands()) {
            if (x instanceof OWLClass) {
                elts.add((OWLClass) x);
            }
            else if (x instanceof OWLObjectSomeValuesFrom) {
                OWLObjectPropertyExpression p = ((OWLObjectSomeValuesFrom)x).getProperty();
                String pLabel = getGraph().getLabel(p);
                if (pLabel != null && pLabel.contains("regulates")) {
                    // fairly hacky:
                    //  fail on this for now - no inference for regulates
                    //elts.add(x);
                    return false;
                }
                else {
                    OWLClassExpression filler = ((OWLObjectSomeValuesFrom)x).getFiller();
                    if (!getReachableOWLClasses( filler, elts)) {
                        return false;
                    }
                }
            }
            else {
                return false;
            }

        }
        return true;
    }
    else if (c instanceof OWLClass) {
        elts.add((OWLClass) c);
        return true;
    }
    return false;
}
项目:Hermit_1.3.8_android    文件:ObjectPropertyInclusionManager.java   
public int rewriteNegativeObjectPropertyAssertions(OWLDataFactory factory,OWLAxioms axioms,int replacementIndex) {
    // now object property inclusion manager added all non-simple properties to axioms.m_complexObjectPropertyExpressions
    // now that we know which roles are non-simple, we can decide which negative object property assertions have to be
    // expressed as concept assertions so that transitivity rewriting applies properly. All new concepts for the concept
    // assertions must be normalised, because we are done with the normal normalisation phase.
    Set<OWLIndividualAxiom> redundantFacts=new HashSet<OWLIndividualAxiom>();
    Set<OWLIndividualAxiom> additionalFacts=new HashSet<OWLIndividualAxiom>();
    for (OWLIndividualAxiom axiom : axioms.m_facts) {
        if (axiom instanceof OWLNegativeObjectPropertyAssertionAxiom) {
            OWLNegativeObjectPropertyAssertionAxiom negAssertion=(OWLNegativeObjectPropertyAssertionAxiom)axiom;
            OWLObjectPropertyExpression prop=negAssertion.getProperty().getSimplified();
            if (axioms.m_complexObjectPropertyExpressions.contains(prop)) {
                // turn not op(a b) into
                // C(a) and not C or forall op not{b}
                OWLIndividual individual=negAssertion.getObject();
                // neg. op assertions cannot contain anonymous individuals
                OWLClass individualConcept=factory.getOWLClass(IRI.create("internal:nom#"+individual.asOWLNamedIndividual().getIRI().toString()));
                OWLClassExpression notIndividualConcept=factory.getOWLObjectComplementOf(individualConcept);
                OWLClassExpression allNotIndividualConcept=factory.getOWLObjectAllValuesFrom(prop,notIndividualConcept);
                OWLClassExpression definition=factory.getOWLClass(IRI.create("internal:def#"+(replacementIndex++)));
                axioms.m_conceptInclusions.add(new OWLClassExpression[] { factory.getOWLObjectComplementOf(definition), allNotIndividualConcept });
                additionalFacts.add(factory.getOWLClassAssertionAxiom(definition,negAssertion.getSubject()));
                additionalFacts.add(factory.getOWLClassAssertionAxiom(individualConcept,individual));
                redundantFacts.add(negAssertion);
            }
        }
    }
    axioms.m_facts.addAll(additionalFacts);
    axioms.m_facts.removeAll(redundantFacts);
    return replacementIndex;
}
项目:Wolpertinger    文件:WolpertingerTest.java   
/**
   * Smth like
   *    A subClassOf r min 5 B
   *  But we have only a domain with 4 elements ...
   */
  public void testUnsatisfiabilityDoToFixedDomain1() {
    OWLDataFactory factory = OWLManager.getOWLDataFactory();
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();

    OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
    OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B")));
    OWLObjectPropertyExpression roleR = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "r")));

    OWLNamedIndividual indA = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
    OWLNamedIndividual indB = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "b")));
    OWLNamedIndividual indC = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "c")));
    OWLNamedIndividual indD = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "d")));

    OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indA);
    OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(classA, indB);
    OWLIndividualAxiom fact3 = factory.getOWLClassAssertionAxiom(classA, indC);
    OWLIndividualAxiom fact4 = factory.getOWLClassAssertionAxiom(classA, indD);

    OWLObjectMinCardinality exprRmin5B = factory.getOWLObjectMinCardinality(5, roleR, classB);
    OWLSubClassOfAxiom axmAsubRsomeB = factory.getOWLSubClassOfAxiom(classA, exprRmin5B);

    try {
    OWLOntology ontology = manager.createOntology();
    manager.addAxiom(ontology, fact1);
    manager.addAxiom(ontology, fact2);
    manager.addAxiom(ontology, fact3);
    manager.addAxiom(ontology, fact4);
    manager.addAxiom(ontology, axmAsubRsomeB);

    Wolpertinger wolpertinger = new Wolpertinger(ontology);

    assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
    e.printStackTrace();
    fail();
}
  }
项目:Wolpertinger    文件:DebugTranslation.java   
/**
 * Disjoint Properties are translated into constraints:</br>
 * <code>:- r(X,Y), s(X,Y), ...</code>
 * @see org.semanticweb.owlapi.model.OWLAxiomVisitor#visit(org.semanticweb.owlapi.model.OWLDisjointObjectPropertiesAxiom)
 */

public void visit(OWLDisjointObjectPropertiesAxiom disProperties) {
    writer.write("icons " + ASP2CoreSymbols.IMPLICATION);
    writer.write(String.format(" activated(%d), ", nConstraints++));
    String cVar = var.currentVar();
    String nVar = var.nextVariable();

    boolean isFirst=true;
    for (OWLObjectPropertyExpression property : disProperties.getProperties()) {
        String propertyName = mapper.getPredicateName(property.getNamedProperty());

        if (!isFirst) {
            writer.write(ASP2CoreSymbols.CONJUNCTION);

        }
        isFirst = false;
        writer.write(propertyName);
        writer.write(ASP2CoreSymbols.BRACKET_OPEN);
        writer.write(cVar);
        writer.write(ASP2CoreSymbols.ARG_SEPERATOR);
        writer.write(nVar);
        writer.write(ASP2CoreSymbols.BRACKET_CLOSE);
    }

    writer.write(ASP2CoreSymbols.EOR);
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public NodeSet<OWLObjectPropertyExpression> getSuperObjectProperties(
        OWLObjectPropertyExpression propertyExpression, boolean direct) {
    HierarchyNode<Role> node = getHierarchyNode(propertyExpression);
    Set<HierarchyNode<Role>> result = new HashSet<HierarchyNode<Role>>();
    if (direct)
        for (HierarchyNode<Role> n : node.getParentNodes())
            result.add(n);
    else {
        result = node.getAncestorNodes();
        result.remove(node);
    }
    return objectPropertyHierarchyNodesToNodeSet(result);
}
项目:owltools    文件:OWLGraphEdge.java   
public OWLGraphEdge(OWLObject source, OWLObject target, List<OWLQuantifiedProperty> qpl, 
        OWLOntology ontology, Set<OWLAxiom> axioms, 
        OWLClass gciFiller, OWLObjectPropertyExpression gciRelation) {
    this(source, target, qpl, ontology);
    if (axioms != null) {
        this.underlyingAxioms.addAll(axioms);
    }
    this.gciFiller = gciFiller;
    this.gciRelation = gciRelation;
}
项目:Wolpertinger    文件:NaiveTranslation.java   
private void createComplexInclusion(ComplexObjectPropertyInclusion complexObjPropertyInclusion) {
    LinkedList<String> chainPredicateNameList = new LinkedList<String> ();
    for (OWLObjectPropertyExpression e : complexObjPropertyInclusion.m_subObjectProperties) {
        chainPredicateNameList.add(mapper.getPredicateName(e.getObjectPropertiesInSignature().iterator().next()));
    }
    String superPropertyName = (mapper.getPredicateName(complexObjPropertyInclusion.m_superObjectProperty.getNamedProperty()));

    int counter = 1;
    writer.print(":-");
    for (String subPropertyName : chainPredicateNameList) {
        writer.print(String.format("%s(X%d,X%d),", subPropertyName, counter, ++counter));
    }
    writer.print(String.format("not %s(X%d,X%d).", superPropertyName, 1, counter));
}
项目:elk-reasoner    文件:ElkReasoner.java   
@Override
public NodeSet<OWLNamedIndividual> getObjectPropertyValues(
        OWLNamedIndividual arg0, OWLObjectPropertyExpression arg1)
        throws InconsistentOntologyException, FreshEntitiesException,
        ReasonerInterruptedException, TimeOutException {
    LOGGER_.trace(
            "getObjectPropertyValues(OWLNamedIndividual, OWLObjectPropertyExpression)");

    checkInterrupted();
    // TODO Provide implementation
    throw unsupportedOwlApiMethod(
            "getObjectPropertyValues(OWLNamedIndividual, OWLObjectPropertyExpression)");
}
项目:logmap-matcher    文件:StructuralReasoner2.java   
private void dumpObjectPropertyHierarchy(Node<OWLObjectPropertyExpression> cls, int level, boolean showBottomNode) {
    if (!showBottomNode && cls.isBottomNode()) {
        return;
    }
    printIndent(level);
    OWLObjectPropertyExpression representative = cls.getRepresentativeElement();
    System.out.println(getEquivalentObjectProperties(representative));
    for (Node<OWLObjectPropertyExpression> subProp : getSubObjectProperties(representative, true)) {
        dumpObjectPropertyHierarchy(subProp, level + 1, showBottomNode);
    }
}
项目:owltools    文件:TemplatedTransformer.java   
private BindingSet unify(OWLObjectPropertyExpression p,
        OWLObjectPropertyExpression template,  Set<IRI> vars) {
    if (p instanceof OWLObjectProperty && template instanceof OWLObjectProperty) {
        return unify(((OWLObjectProperty) p).getIRI(),
                ((OWLObjectProperty) template).getIRI(),
                vars);
    }
    if (p instanceof OWLObjectInverseOf && template instanceof OWLObjectInverseOf) {
        return unify(((OWLObjectInverseOf)p).getInverse(),
                ((OWLObjectInverseOf)template).getInverseProperty(),
                vars);
    }
    return null;
}
项目:Wolpertinger    文件:DebugTranslation.java   
/**
 * Asymetric Role Assertion <i>Asy(r)</i> is translated to:</br>
 * </br>
 * :- r(X,Y),r(Y,X).
 *
 * @see org.semanticweb.owlapi.model.OWLAxiomVisitor#visit(org.semanticweb.owlapi.model.OWLAsymmetricObjectPropertyAxiom)
 */

public void visit(OWLAsymmetricObjectPropertyAxiom asymetricProperty) {
    OWLObjectPropertyExpression property = asymetricProperty.getProperty();

    String propertyName = mapper.getPredicateName(property.getNamedProperty());
    String cVar = var.currentVar();
    String nVar = var.nextVariable();

    writer.write("icons " + ASP2CoreSymbols.IMPLICATION);
    writer.write(String.format(" activated(%d), ", nConstraints++));
    writer.write(propertyName);
    writer.write(ASP2CoreSymbols.BRACKET_OPEN);
    writer.write(cVar);
    writer.write(ASP2CoreSymbols.ARG_SEPERATOR);
    writer.write(nVar);
    writer.write(ASP2CoreSymbols.BRACKET_CLOSE);
    writer.write(ASP2CoreSymbols.CONJUNCTION);
    //writer.write(ASP2CoreSymbols.NAF);
    //writer.write(ASP2CoreSymbols.SPACE);
    writer.write(propertyName);
    writer.write(ASP2CoreSymbols.BRACKET_OPEN);
    writer.write(nVar);
    writer.write(ASP2CoreSymbols.ARG_SEPERATOR);
    writer.write(cVar);
    writer.write(ASP2CoreSymbols.BRACKET_CLOSE);
    writer.write(ASP2CoreSymbols.EOR);
}
项目:jcel    文件:JcelReasoner.java   
@Override
public Node<OWLObjectPropertyExpression> getBottomObjectPropertyNode() {
    logger.finer("getBottomObjectPropertyNode()");
    Node<OWLObjectPropertyExpression> ret = getTranslator()
            .translateSOPE(getReasoner().getBottomObjectPropertyNode());
    logger.finer("" + ret);
    return ret;
}
项目:skoseditor    文件:SKOSObjectPropertyIndividualPairEditor.java   
public void setObjectPropertyAxiom(
            OWLPropertyAssertionAxiom<OWLObjectPropertyExpression, OWLNamedIndividual> ax) {
//      OWLObjectPropertyExpression p = ax.getProperty();
//      if (p instanceof OWLObjectProperty) {
//          this.objectPropertyPanel.setSelection((OWLObjectProperty) p);
//      }
        this.individualSelectorPanel.setSelection(ax.getObject());
    }
项目:owltools    文件:OWLInAboxTranslator.java   
/**
 * Transitive(R) ==> Transitive(R')
 * 
 * @param ax
 */
private void tr(OWLObjectPropertyCharacteristicAxiom ax) {
    if (ax instanceof OWLTransitiveObjectPropertyAxiom) {
        OWLObjectPropertyExpression pt = trTypeLevel(ax.getProperty());
        if (pt instanceof OWLObjectProperty) {
            add(getOWLDataFactory().getOWLTransitiveObjectPropertyAxiom(pt));
        }
    }
    add(ax); // pass-through
}
项目:jcel    文件:JcelReasoner.java   
@Override
public Node<OWLObjectPropertyExpression> getInverseObjectProperties(
        OWLObjectPropertyExpression objectPropertyExpression) throws InconsistentOntologyException,
        FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
    Objects.requireNonNull(objectPropertyExpression);
    logger.finer("getInverseObjectProperties(" + objectPropertyExpression + ")");
    throw new UnsupportedReasonerOperationInJcelException(
            "Unsupported operation : getInverseObjectProperties(OWLObjectPropertyExpression)");
}
项目:elk-reasoner    文件:AbstractElkObjectConverter.java   
Set<OWLObjectPropertyExpression> toObjectPropertyExpressionSet(
        List<? extends ElkObjectPropertyExpression> input) {
    Set<OWLObjectPropertyExpression> result = new HashSet<OWLObjectPropertyExpression>(
            input.size());
    for (ElkObjectPropertyExpression next : input) {
        result.add(convert(next));
    }
    return result;
}
项目:owltools    文件:OWLGraphWrapperEdgesExtendedTest.java   
/**
 * Test {@link OWLGraphWrapperEdgesExtended#getSubPropertiesOf(OWLObjectPropertyExpression)}.
 */
@Test
public void shouldGetSubPropertiesOf()
{
    OWLObjectProperty fakeRel1 = 
            wrapper.getOWLObjectPropertyByIdentifier("fake_rel1");
    OWLObjectProperty fakeRel2 = 
            wrapper.getOWLObjectPropertyByIdentifier("fake_rel2");
    //fake_rel2 is the only sub-property of fake_rel1
    Set<OWLObjectPropertyExpression> subprops = wrapper.getSubPropertiesOf(fakeRel1);
    assertTrue("Incorrect sub-properties returned: " + subprops, 
            subprops.size() == 1 && subprops.contains(fakeRel2));

}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
protected NodeSet<OWLObjectPropertyExpression> objectPropertyHierarchyNodesToNodeSet(
        Collection<HierarchyNode<Role>> hierarchyNodes) {
    Set<Node<OWLObjectPropertyExpression>> result = new HashSet<Node<OWLObjectPropertyExpression>>();
    for (HierarchyNode<Role> hierarchyNode : hierarchyNodes) {
        result.add(objectPropertyHierarchyNodeToNode(hierarchyNode));
    }
    return new OWLObjectPropertyNodeSet(result);
}