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

项目:ontocomplib    文件:ELIndividualContext.java   
/**
 * Asserts that the given individual is an instance of the complement of the given type.
 * @param type the given type
 * @param indObj the given individual about which the assertion will be made
 * @return <code>true</code> if the assertion is successful
 */
@Override
public boolean addNegatedAttributeToObject(OWLClass type,IndividualObject indObj) {
    OWLClassAssertionAxiom axiom = getFactory().getOWLClassAssertionAxiom(
            ELIndividualObject.getComplement(getOntology(), type),
            indObj.getIdentifier());
    AddAxiom  addAxiom = new AddAxiom(getOntology(),axiom); 
    try {
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        updateObjects(Constants.AFTER_MODIFICATION);
        updateObjectDescriptions(Constants.AFTER_MODIFICATION);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    getHistory().push(new ClassAssertionChange(this,addAxiom,indObj.getIdentifier(),type,true));
    return true;
}
项目:ontocomplib    文件:IndividualContext.java   
/**
 * Adds a given individual to the ontology as an instance of <code>Thing</code>
 * @param object the given object to be added
 * @return <code>true</code> if the object is successfully added
 */
// @Override
public boolean addIndividualToOntology(OWLNamedIndividual object) {
    OWLClassAssertionAxiom axiom = getFactory().getOWLClassAssertionAxiom(getFactory().getOWLThing(), object);
    AddAxiom  addAxiom = new AddAxiom(getOntology(),axiom); 
    Set<OWLClass> attrs = new HashSet<OWLClass>();
    try {
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        IndividualObject indObj = createIndividualObject(object);
        indObj.updateDescription(Constants.AFTER_MODIFICATION);
        addObject(indObj);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    attrs.add(getFactory().getOWLThing());
    getHistory().push(new NewIndividualChange(this,addAxiom,object,attrs));
    return true;
}
项目:ontocomplib    文件:IndividualContext.java   
/**
 * Adds a given individual to the ontology as an instance of the conjunction of the 
 * given set of classes
 * @param object the individual to be added
 * @param attributes the set of classes
 * @return <code>true</code> if the individual is successfully added
 */
public boolean addIndividualToOntology(OWLNamedIndividual object, Set<OWLClass> attributes) {
    // OWLObjectIntersectionOf description = toOWLDescription(attributes);
    OWLClassExpression description = toOWLDescription(attributes);
    OWLClassAssertionAxiom axiom = getFactory().getOWLClassAssertionAxiom(description, object);
    AddAxiom  addAxiom = new AddAxiom(getOntology(),axiom); 
    try {
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        IndividualObject indObj = createIndividualObject(object);
        // for (OWLClass attribute : attributes) {
        //  indObj.getDescription().addAttribute(attribute);
        // }
        indObj.getDescription().addAttributes(attributes);
        indObj.updateDescription(Constants.AFTER_MODIFICATION);
        addObject(indObj);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    getHistory().push(new NewIndividualChange(this,addAxiom,object,attributes));
    return true;
}
项目:ontocomplib    文件:IndividualContext.java   
/**
 * Asserts that the given individual is an instance of the given type.
 * @param type the given type
 * @param indObj the given individual about which the assertion will be made
 * @return <code>true</code> if the assertion is successful
 */
public boolean addAttributeToObject(OWLClass type,IndividualObject indObj) {
    OWLClassAssertionAxiom axiom = getFactory().getOWLClassAssertionAxiom(type, indObj.getIdentifier());
    AddAxiom  addAxiom = new AddAxiom(getOntology(),axiom); 
    try {
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        updateObjects(Constants.AFTER_MODIFICATION);
        updateObjectDescriptions(Constants.AFTER_MODIFICATION);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    getHistory().push(new ClassAssertionChange(this,addAxiom,indObj.getIdentifier(),type,false));
    return true;
}
项目:ontocomplib    文件:IndividualContext.java   
/**
 * Asserts that the given individual is an instance of the complement of the given type.
 * @param type the given type
 * @param indObj the given individual about which the assertion will be made
 * @return <code>true</code> if the assertion is successful
 */
public boolean addNegatedAttributeToObject(OWLClass type,IndividualObject indObj) {
    OWLClassAssertionAxiom axiom = getFactory().getOWLClassAssertionAxiom(getFactory().getOWLObjectComplementOf(type), indObj.getIdentifier());
    AddAxiom  addAxiom = new AddAxiom(getOntology(),axiom); 
    try {
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        updateObjects(Constants.AFTER_MODIFICATION);
        updateObjectDescriptions(Constants.AFTER_MODIFICATION);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    getHistory().push(new ClassAssertionChange(this,addAxiom,indObj.getIdentifier(),type,true));
    return true;
}
项目:ontocomplib    文件:CounterExampleCandidateDescriptionChange.java   
public void undo() {
    OWLClassAssertionAxiom axiom = null;
    if (isTypePlus) {
        axiom = theContext.getFactory().getOWLClassAssertionAxiom(changedType, candidate);
    }
    else {
        axiom = theContext.getFactory().getOWLClassAssertionAxiom( 
                theContext.getFactory().getOWLObjectComplementOf(changedType), candidate);
    }
    RemoveAxiom  removeAxiom = new RemoveAxiom(theContext.getOntology(),axiom); 
    try {
        theContext.getManager().applyChange(removeAxiom);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
private static Pair<OWLNamedIndividual, Set<OWLAxiom>> createIndividualInternal(IRI iri, OWLOntology abox, OWLClassExpression ce, Set<OWLAnnotation> annotations) {
    LOG.info("Generating individual for IRI: "+iri);
    OWLDataFactory f = abox.getOWLOntologyManager().getOWLDataFactory();
    OWLNamedIndividual i = f.getOWLNamedIndividual(iri);

    // create axioms
    Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
    // declaration
    axioms.add(f.getOWLDeclarationAxiom(i));
    // annotation assertions
    if(annotations != null) {
        for(OWLAnnotation annotation : annotations) {
            axioms.add(f.getOWLAnnotationAssertionAxiom(iri, annotation));
        }
    }

    if (ce != null) {
        OWLClassAssertionAxiom typeAxiom = createType(f, i, ce);
        if (typeAxiom != null) {
            axioms.add(typeAxiom);
        }
    }

    return Pair.of(i, axioms);
}
项目:logmap-matcher    文件:StructuralReasoner2.java   
public NodeSet<OWLClass> getTypes(OWLNamedIndividual ind, boolean direct) throws InconsistentOntologyException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
    ensurePrepared();
    DefaultNodeSet<OWLClass> result = new OWLClassNodeSet();
    for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
        for (OWLClassAssertionAxiom axiom : ontology.getClassAssertionAxioms(ind)) {
            OWLClassExpression ce = axiom.getClassExpression();
            if (!ce.isAnonymous()) {
                result.addNode(classHierarchyInfo.getEquivalents(ce.asOWLClass()));
                if (!direct) {
                    result.addAllNodes(getSuperClasses(ce, false).getNodes());
                }
            }
        }
    }
    return result;
}
项目:HermiT-android    文件:Reasoner.java   
public boolean isSatisfiable(OWLClassExpression classExpression) {
    checkPreConditions(classExpression);
    if (!isConsistent())
        return false;
    if (classExpression instanceof OWLClass
            && m_atomicConceptHierarchy != null) {
        AtomicConcept concept = H((OWLClass) classExpression);
        HierarchyNode<AtomicConcept> node = m_atomicConceptHierarchy
                .getNodeForElement(concept);
        return node != m_atomicConceptHierarchy.getBottomNode();
    } else {
        OWLDataFactory factory = getDataFactory();
        OWLIndividual freshIndividual = factory
                .getOWLAnonymousIndividual("fresh-individual");
        OWLClassAssertionAxiom assertClassExpression = factory
                .getOWLClassAssertionAxiom(classExpression, freshIndividual);
        Tableau tableau = getTableau(assertClassExpression);
        return tableau.isSatisfiable(true, null, null, null, null, null,
                ReasoningTaskDescription
                        .isConceptSatisfiable(classExpression));
    }
}
项目:HermiT-android    文件:EntailmentChecker.java   
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) {
    reasoner.throwInconsistentOntologyExceptionIfNecessary();
    if (!reasoner.isConsistent())
        return true;
    if (reasoner.m_dlOntology.hasDatatypes()) {
        OWLDataFactory factory=reasoner.getDataFactory();
        OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual");
        OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property"));
        OWLDataRange dataRange=axiom.getDataRange();
        OWLDatatype dt=axiom.getDatatype();
        OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt);
        OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange);
        OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2);
        OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union);
        OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual);
        Tableau tableau=reasoner.getTableau(ax);
        return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom));
    }
    else
        return false;
}
项目:HermiT-android    文件:EntailmentChecker.java   
public void visit(OWLClassAssertionAxiom axiom) {
    if (axiom.getClassExpression().isOWLThing())
        return;
    OWLIndividual node=axiom.getIndividual();
    if (!node.isAnonymous()) {
        namedNodes.add(node.asOWLNamedIndividual());
    }
    else {
        nodes.add(node.asOWLAnonymousIndividual());
        if (nodelLabels.containsKey(node)) {
            nodelLabels.get(node).add(axiom.getClassExpression());
        }
        else {
            Set<OWLClassExpression> label=new HashSet<OWLClassExpression>();
            label.add(axiom.getClassExpression());
            nodelLabels.put(node.asOWLAnonymousIndividual(),label);
        }
    }
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public boolean isSatisfiable(OWLClassExpression classExpression) {
    checkPreConditions(classExpression);
    if (!isConsistent())
        return false;
    if (classExpression instanceof OWLClass
            && m_atomicConceptHierarchy != null) {
        AtomicConcept concept = H((OWLClass) classExpression);
        HierarchyNode<AtomicConcept> node = m_atomicConceptHierarchy
                .getNodeForElement(concept);
        return node != m_atomicConceptHierarchy.getBottomNode();
    } else {
        OWLDataFactory factory = getDataFactory();
        OWLIndividual freshIndividual = factory
                .getOWLAnonymousIndividual("fresh-individual");
        OWLClassAssertionAxiom assertClassExpression = factory
                .getOWLClassAssertionAxiom(classExpression, freshIndividual);
        Tableau tableau = getTableau(assertClassExpression);
        return tableau.isSatisfiable(true, null, null, null, null, null,
                ReasoningTaskDescription
                        .isConceptSatisfiable(classExpression));
    }
}
项目:Hermit_1.3.8_android    文件:EntailmentChecker.java   
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) {
    reasoner.throwInconsistentOntologyExceptionIfNecessary();
    if (!reasoner.isConsistent())
        return true;
    if (reasoner.m_dlOntology.hasDatatypes()) {
        OWLDataFactory factory=reasoner.getDataFactory();
        OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual");
        OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property"));
        OWLDataRange dataRange=axiom.getDataRange();
        OWLDatatype dt=axiom.getDatatype();
        OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt);
        OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange);
        OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2);
        OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union);
        OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual);
        Tableau tableau=reasoner.getTableau(ax);
        return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom));
    }
    else
        return false;
}
项目:Hermit_1.3.8_android    文件:EntailmentChecker.java   
public void visit(OWLClassAssertionAxiom axiom) {
    if (axiom.getClassExpression().isOWLThing())
        return;
    OWLIndividual node=axiom.getIndividual();
    if (!node.isAnonymous()) {
        namedNodes.add(node.asOWLNamedIndividual());
    }
    else {
        nodes.add(node.asOWLAnonymousIndividual());
        if (nodelLabels.containsKey(node)) {
            nodelLabels.get(node).add(axiom.getClassExpression());
        }
        else {
            Set<OWLClassExpression> label=new HashSet<OWLClassExpression>();
            label.add(axiom.getClassExpression());
            nodelLabels.put(node.asOWLAnonymousIndividual(),label);
        }
    }
}
项目:owltools    文件:Sim2CommandRunner.java   
@CLIMethod("--remove-dangling-annotations")
public void removeDangningAnnotations(Opts opts) throws Exception {
    OWLOntology ont = g.getSourceOntology();
    int n = 0;
    Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
    for (OWLNamedIndividual i : ont.getIndividualsInSignature()) {
        for (OWLClassAssertionAxiom ca : ont.getClassAssertionAxioms(i)) {
            OWLClassExpression cx = ca.getClassExpression();
            if (cx instanceof OWLClass) {
                OWLClass c = (OWLClass) cx;
                String label = g.getLabel(c);
                if (label == null)
                    rmAxioms.add(ca);
                else
                    n++;
            }
        }
    }
    LOG.info("Removing " + rmAxioms.size() + " axioms");
    ont.getOWLOntologyManager().removeAxioms(ont, rmAxioms);
    LOG.info("Remaining: " + n + " axioms");
}
项目:owltools    文件:AbstractSimPreProcessor.java   
public Set<OWLClass> materializeClassExpressionsReferencedBy(OWLObjectProperty p) {
    Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>();
    for (OWLAxiom ax : outputOntology.getReferencingAxioms(p, Imports.INCLUDED)) {
        if (ax instanceof OWLSubClassOfAxiom) {
            xs.addAll(getClassExpressionReferencedBy(p, ((OWLSubClassOfAxiom)ax).getSuperClass()));
        }
        else if (ax instanceof OWLClassAssertionAxiom) {
            xs.addAll(getClassExpressionReferencedBy(p, ((OWLClassAssertionAxiom)ax).getClassExpression()));
        }
        else if (ax instanceof OWLEquivalentClassesAxiom) {
            for (OWLClassExpression x : ((OWLEquivalentClassesAxiom)ax).getClassExpressions()) {
                xs.addAll(getClassExpressionReferencedBy(p,x));
            }
        }
    }
    return materializeClassExpressions(xs);
}
项目:owltools    文件:ABoxUtils.java   
public static void randomizeClassAssertions(OWLOntology ont, int num) {
    Set<OWLClassAssertionAxiom> caas = new HashSet<OWLClassAssertionAxiom>();
    Set<OWLClassAssertionAxiom> caasNew = new HashSet<OWLClassAssertionAxiom>();
        Set<OWLNamedIndividual> inds = ont.getIndividualsInSignature(Imports.INCLUDED);
    OWLNamedIndividual[] indArr = (OWLNamedIndividual[]) inds.toArray();
    for (OWLNamedIndividual ind : inds) {
        caas.addAll( ont.getClassAssertionAxioms(ind) );
    }
    for (OWLClassAssertionAxiom caa : caas) {
        OWLIndividual randomIndividual = null;
        caasNew.add(ont.getOWLOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(caa.getClassExpression(), 
                randomIndividual));
    }
    ont.getOWLOntologyManager().removeAxioms(ont, caas);
    ont.getOWLOntologyManager().addAxioms(ont, caasNew);
}
项目:owltools    文件:PhenoSimHQEPreProcessor.java   
protected void makeHasPhenotypeInstancesDirect() {
    // x Type has_phenotype some C ==> x Type C
    LOG.info("x Type has_phenotype some C ==> x Type C");
    OWLObjectProperty hasPhenotype = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE);
    Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
    Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>();
    for (OWLClassAssertionAxiom caa : outputOntology.getAxioms(AxiomType.CLASS_ASSERTION)) {
        OWLClassExpression ex = caa.getClassExpression();
        OWLIndividual i = caa.getIndividual();
        if (ex instanceof OWLObjectSomeValuesFrom) {
            OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ex;
            if (svf.getProperty().equals(hasPhenotype)) {
                rmAxioms.add(caa);
                newAxioms.add(getOWLDataFactory().getOWLClassAssertionAxiom(svf.getFiller(), i));
            }

        }
    }
    LOG.info("making instances direct: +"+newAxioms.size()+ " -"+rmAxioms.size());
    addAxiomsToOutput(newAxioms, false);
    removeAxiomsFromOutput(rmAxioms, false);
}
项目:Wolpertinger    文件:NiceAxiomPrinter.java   
public void visit(OWLClassAssertionAxiom classAssertion) {
    OWLIndividual individual = classAssertion.getIndividual();
    OWLClassExpression classExpression = classAssertion.getClassExpression();

    if (!classExpression.isAnonymous()) {
        OWLClass namedClass = classExpression.asOWLClass();

        writer.print(namedClass.getIRI().getFragment());
        writer.print("(");
        writer.print(IRI.create(individual.toStringID()).getFragment());
        writer.print(").\n");
    }
    else {

    }
}
项目:Pellet4Android    文件:OntologyManager.java   
/**
 * Create an individual of a given type
 * 
 * @param individual
 *            the individual signature
 * @param type
 *            individual type
 */

public void createIndividual(final String individual, final String type) {
    OWLDataFactory factory = ontology.getOWLOntologyManager()
            .getOWLDataFactory();

    OWLClass clazz = factory.getOWLClass(IRI.create(type));

    OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI
            .create(individual));
    OWLClassAssertionAxiom assertion = factory.getOWLClassAssertionAxiom(
            clazz, ind);
    final List<OWLOntologyChange> owlOntologyChanges = ontology
            .getOWLOntologyManager().addAxiom(ontology, assertion);
    manager.applyChanges(owlOntologyChanges);
    reasoner.flush();
}
项目:Pellet4Android    文件:OntologyManager.java   
/**
 * Add a new class membership to an individual
 * 
 * @param individual
 *            the individual signature
 * @param type
 *            individual type
 */

public void addIndividualMembership(final String individual,
        final String type) {
    OWLDataFactory factory = ontology.getOWLOntologyManager()
            .getOWLDataFactory();

    OWLClass clazz = factory.getOWLClass(IRI.create(type));

    OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI
            .create(individual));
    OWLClassAssertionAxiom assertion = factory.getOWLClassAssertionAxiom(
            clazz, ind);
    final List<OWLOntologyChange> owlOntologyChanges = ontology
            .getOWLOntologyManager().addAxiom(ontology, assertion);
    manager.applyChanges(owlOntologyChanges);
    reasoner.flush();
}
项目:Pellet4Android    文件:OntologyManager.java   
/**
 * Remove class membership from an individual
 * 
 * @param individual
 *            the individual signature
 * @param type
 *            individual type
 */
//
public void removeIndividualMembership(final String individual,
        final String type) {
    OWLDataFactory factory = ontology.getOWLOntologyManager()
            .getOWLDataFactory();

    OWLClass clazz = factory.getOWLClass(IRI.create(type));

    OWLNamedIndividual ind = factory.getOWLNamedIndividual(IRI
            .create(individual));
    OWLClassAssertionAxiom assertion = factory.getOWLClassAssertionAxiom(
            clazz, ind);
    final List<OWLOntologyChange> owlOntologyChanges = ontology
            .getOWLOntologyManager().removeAxiom(ontology, assertion);
    manager.applyChanges(owlOntologyChanges);
    reasoner.flush();
}
项目:ppinot    文件:GeneratePpinotAxioms.java   
/**
 * Genera los axiomas correspondientes a un PPI
 * 
 * @param element Objeto del modelo del PPI
 * @param bpmn20ModelHandler Manejador del modelo BPMN correspondiente al mismo proceso del PPI
 * @return Objeto OWL de la medida
 * @throws Exception
 */
void converterPpiOWL(PPI element, Bpmn20ModelHandlerInterface bpmn20ModelHandler) throws Exception {

    String ppiId = element.getId();

    MeasureDefinition measuredBy = element.getMeasuredBy();
    String measureId = measuredBy.getId();

    // adiciona el axioma que indica la clase del PPI
    OWLNamedIndividual ppiIndividual = factory.getOWLNamedIndividual( IRI.create(ppinotGeneratedOntologyURI+"#"+ppiId) );
    OWLClass ppiClass = factory.getOWLClass( IRI.create(Vocabulary.PPI_URI));
    OWLClassAssertionAxiom ppiClassAxiom = factory.getOWLClassAssertionAxiom(ppiClass, ppiIndividual);
    manager.addAxiom(ontology, ppiClassAxiom);

    // adiciona el axioma con la relacion entre el PPI y la medida
    OWLObjectPropertyExpression definition = factory.getOWLObjectProperty(IRI.create(Vocabulary.DEFINITION_URI));
    OWLNamedIndividual measureIndividual = factory.getOWLNamedIndividual( IRI.create(ppinotGeneratedOntologyURI+"#"+measureId) );
    OWLObjectPropertyAssertionAxiom definitionAxiom = factory.getOWLObjectPropertyAssertionAxiom(definition, ppiIndividual, measureIndividual);
    manager.addAxiom(ontology, definitionAxiom);
}
项目:ontocomplib    文件:IndividualObject.java   
public boolean hasType(OWLClassExpression type, OWLNamedIndividual individual) {
    boolean ret = false;
    Set<OWLClassAssertionAxiom> set = getContext().getReasoner().getRootOntology().getClassAssertionAxioms(individual);
    for (OWLClassAssertionAxiom axiom : set) {
        ret = ret || getContext().isSubClassOf(axiom.getClassExpression(), type);
    }
    return ret;
}
项目:minerva    文件:LegoModelWalker.java   
private Set<OWLObjectSomeValuesFrom> getSvfTypes(OWLNamedIndividual i, OWLOntology model) {
    Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(i);
    final Set<OWLObjectSomeValuesFrom> svfs = new HashSet<OWLObjectSomeValuesFrom>();
    for (OWLClassAssertionAxiom axiom : axioms) {
        axiom.getClassExpression().accept(new OWLClassExpressionVisitorAdapter(){

            @Override
            public void visit(OWLObjectSomeValuesFrom svf) {
                svfs.add(svf);
            }
        });
    }
    return svfs;
}
项目:minerva    文件:LegoModelWalker.java   
private Set<OWLClass> getTypes(OWLNamedIndividual i, OWLOntology model) {
    Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(i);
    Set<OWLClass> types = new HashSet<OWLClass>();
    for (OWLClassAssertionAxiom axiom : axioms) {
        OWLClassExpression ce = axiom.getClassExpression();
        if (ce instanceof OWLClass) {
            OWLClass cls = ce.asOWLClass();
            if (cls.isBuiltIn() == false) {
                types.add(cls);
            }
        }
    }
    return types;
}
项目:minerva    文件:CoreMolecularModelManager.java   
/**
 * Adds a ClassAssertion, where the class expression instantiated is an
 * ObjectSomeValuesFrom expression
 * 
 * Example: Individual: i Type: enabledBy some PRO_123
 *  
 * @param model
 * @param i
 * @param p
 * @param filler
 * @param metadata
 */
void addType(ModelContainer model,
        OWLIndividual i, 
        OWLObjectPropertyExpression p,
        OWLClassExpression filler,
        METADATA metadata) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Adding "+i+ " type "+p+" some "+filler); 
    }
    OWLDataFactory f = model.getOWLDataFactory();
    OWLObjectSomeValuesFrom c = f.getOWLObjectSomeValuesFrom(p, filler);
    OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(c, i);
    addAxiom(model, axiom, metadata);
}
项目:minerva    文件:CoreMolecularModelManager.java   
/**
 * remove ClassAssertion(c,i) from the model
 * 
 * @param model
 * @param i
 * @param ce
 * @param metadata
 */
public void removeType(ModelContainer model, OWLIndividual i, 
        OWLClassExpression ce, METADATA metadata) {
    Set<OWLClassAssertionAxiom> allAxioms = model.getAboxOntology().getClassAssertionAxioms(i);
    // use search to remove also axioms with annotations
    for (OWLClassAssertionAxiom ax : allAxioms) {
        if (ce.equals(ax.getClassExpression())) {
            removeAxiom(model, ax, metadata);
        }
    }

}
项目: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);
}
项目:Source    文件:OntoModel.java   
private void addClassAssertionAxiom(OWLClass classname, OWLIndividual individ) {
    // pipe1 (individual) belongs to the class Pipe
    OWLClassAssertionAxiom assertion = dataFactory.getOWLClassAssertionAxiom(classname, individ);
    AddAxiom addAxiom = new AddAxiom(ontology, assertion);
    manager.applyChange(addAxiom);
    countClassAssertionAxioms++;
    log.log(Level.FINER, "The class assertion axiom was added: " + assertion.toString());
}
项目:logmap-matcher    文件:StructuralReasoner2.java   
public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
    ensurePrepared();
    DefaultNodeSet<OWLNamedIndividual> result = new OWLNamedIndividualNodeSet();
    if (!ce.isAnonymous()) {
        OWLClass cls = ce.asOWLClass();
        Set<OWLClass> clses = new HashSet<OWLClass>();
        clses.add(cls);
        if (!direct) {
            clses.addAll(getSubClasses(cls, false).getFlattened());
        }
        for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
            for (OWLClass curCls : clses) {
                for (OWLClassAssertionAxiom axiom : ontology.getClassAssertionAxioms(curCls)) {
                    OWLIndividual individual = axiom.getIndividual();
                    if (!individual.isAnonymous()) {
                        if (getIndividualNodeSetPolicy().equals(IndividualNodeSetPolicy.BY_SAME_AS)) {
                            result.addNode(getSameIndividuals(individual.asOWLNamedIndividual()));
                        }
                        else {
                            result.addNode(new OWLNamedIndividualNode(individual.asOWLNamedIndividual()));
                        }
                    }
                }
            }
        }
    }
    return result;
}
项目:skoseditor    文件:SKOSConceptSchemeInferredHierarchyViewComponent.java   
public Set<OWLNamedIndividual> getConceptSchemes () {

        Set<OWLNamedIndividual> inds = new HashSet<OWLNamedIndividual>(10);

        for (OWLOntology onto  : getOWLEditorKit().getModelManager().getOntologies()) {
            Set<OWLClassAssertionAxiom> axioms = onto.getClassAssertionAxioms(getOWLEditorKit().getModelManager().getOWLDataFactory().getOWLClass(SKOSVocabulary.CONCEPTSCHEME.getIRI()));
            for (OWLClassAssertionAxiom axiom : axioms) {
                inds.add(axiom.getIndividual().asOWLNamedIndividual());
            }

        }
        return inds;
    }
项目:skoseditor    文件:ConceptSchemeComboBox.java   
public static Set<OWLIndividual> getConceptSchemes (OWLEditorKit owlEditorKit) {

        Set<OWLIndividual> inds = new HashSet<OWLIndividual>();

        for (OWLOntology onto  : owlEditorKit.getModelManager().getOntologies()) {
            Set<OWLClassAssertionAxiom> axioms = onto.getClassAssertionAxioms(owlEditorKit.getModelManager().getOWLDataFactory().getOWLClass(SKOSVocabulary.CONCEPTSCHEME.getIRI()));
            for (OWLClassAssertionAxiom clssAx : axioms) {
                inds.add(clssAx.getIndividual());
            }
        }
        return inds;
    }
项目:HermiT-android    文件:OWLNormalization.java   
public void visit(OWLClassAssertionAxiom axiom) {
    OWLClassExpression classExpression=axiom.getClassExpression();
    if (classExpression instanceof OWLDataHasValue) {
        OWLDataHasValue hasValue=(OWLDataHasValue)classExpression;
        addFact(m_factory.getOWLDataPropertyAssertionAxiom(hasValue.getProperty(), axiom.getIndividual(), hasValue.getValue()));
        return;
    }
    if (classExpression instanceof OWLDataSomeValuesFrom) {
        OWLDataSomeValuesFrom someValuesFrom=(OWLDataSomeValuesFrom)classExpression;
        OWLDataRange dataRange=someValuesFrom.getFiller();
        if (dataRange instanceof OWLDataOneOf) {
            OWLDataOneOf oneOf=(OWLDataOneOf)dataRange;
            if (oneOf.getValues().size()==1) {
                addFact(m_factory.getOWLDataPropertyAssertionAxiom(someValuesFrom.getProperty(),axiom.getIndividual(),oneOf.getValues().iterator().next()));
                return;
            }
        }
    }
    classExpression=positive(classExpression);
    if (!isSimple(classExpression)) {
        OWLClassExpression definition=getDefinitionFor(classExpression,m_alreadyExists);
        if (!m_alreadyExists[0])
            m_classExpressionInclusionsAsDisjunctions.add(new OWLClassExpression[] { negative(definition),classExpression });
        classExpression=definition;
    }
    addFact(m_factory.getOWLClassAssertionAxiom(classExpression,axiom.getIndividual()));
}
项目:HermiT-android    文件:EntailmentChecker.java   
public Boolean visit(OWLClassAssertionAxiom axiom) {
    OWLIndividual ind=axiom.getIndividual();
    if (ind.isAnonymous()) {
        anonymousIndividualAxioms.add(axiom);
        return true; // will be checked afterwards by rolling-up
    }
    OWLClassExpression c=axiom.getClassExpression();
    return reasoner.hasType(ind.asOWLNamedIndividual(),c,false);
}
项目:elk-reasoner    文件:AbstractOwlAxiomConverterVisitor.java   
@Override
public T visit(OWLClassAssertionAxiom axiom) {
    throw new IllegalArgumentException(
            OWLClassAssertionAxiom.class.getSimpleName()
                    + " cannot be converted to "
                    + getTargetClass().getSimpleName());
}
项目:Hermit_1.3.8_android    文件:OWLNormalization.java   
public void visit(OWLClassAssertionAxiom axiom) {
    OWLClassExpression classExpression=axiom.getClassExpression();
    if (classExpression instanceof OWLDataHasValue) {
        OWLDataHasValue hasValue=(OWLDataHasValue)classExpression;
        addFact(m_factory.getOWLDataPropertyAssertionAxiom(hasValue.getProperty(), axiom.getIndividual(), hasValue.getValue()));
        return;
    }
    if (classExpression instanceof OWLDataSomeValuesFrom) {
        OWLDataSomeValuesFrom someValuesFrom=(OWLDataSomeValuesFrom)classExpression;
        OWLDataRange dataRange=someValuesFrom.getFiller();
        if (dataRange instanceof OWLDataOneOf) {
            OWLDataOneOf oneOf=(OWLDataOneOf)dataRange;
            if (oneOf.getValues().size()==1) {
                addFact(m_factory.getOWLDataPropertyAssertionAxiom(someValuesFrom.getProperty(),axiom.getIndividual(),oneOf.getValues().iterator().next()));
                return;
            }
        }
    }
    classExpression=positive(classExpression);
    if (!isSimple(classExpression)) {
        OWLClassExpression definition=getDefinitionFor(classExpression,m_alreadyExists);
        if (!m_alreadyExists[0])
            m_classExpressionInclusionsAsDisjunctions.add(new OWLClassExpression[] { negative(definition),classExpression });
        classExpression=definition;
    }
    addFact(m_factory.getOWLClassAssertionAxiom(classExpression,axiom.getIndividual()));
}
项目:Hermit_1.3.8_android    文件:EntailmentChecker.java   
public Boolean visit(OWLClassAssertionAxiom axiom) {
    OWLIndividual ind=axiom.getIndividual();
    if (ind.isAnonymous()) {
        anonymousIndividualAxioms.add(axiom);
        return true; // will be checked afterwards by rolling-up
    }
    OWLClassExpression c=axiom.getClassExpression();
    return reasoner.hasType(ind.asOWLNamedIndividual(),c,false);
}
项目:owltools    文件:ModelAnnotationSolrDocumentLoader.java   
private OWLClass findFirstType(OWLNamedIndividual relevant) {
    Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(relevant);
    for (OWLClassAssertionAxiom axiom : axioms) {
        OWLClassExpression ce = axiom.getClassExpression();
        if (ce.isAnonymous() == false) {
            return ce.asOWLClass();
        }
    }
    return null;
}
项目:owltools    文件:ABoxUtils.java   
public static void createRandomClassAssertions(OWLOntology ont, int num, int maxAssertionsPerInstance) {
    Set<OWLClassAssertionAxiom> caasNew = new HashSet<OWLClassAssertionAxiom>();
    Vector<OWLClass> clist = new Vector<OWLClass>(ont.getClassesInSignature(Imports.INCLUDED));
    for (int i=0; i<num; i++) {
        OWLNamedIndividual ind = ont.getOWLOntologyManager().getOWLDataFactory().
        getOWLNamedIndividual(IRI.create("http://x.org/"+i));
        for (int j=0; j< Math.random() * maxAssertionsPerInstance; j++) {
            OWLClass c = clist.get((int)(Math.random() * clist.size()));
            caasNew.add(ont.getOWLOntologyManager().getOWLDataFactory().
                    getOWLClassAssertionAxiom(c, ind));
        }

    }
    ont.getOWLOntologyManager().addAxioms(ont, caasNew);
}