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

项目:OWLAx    文件:IntegrateOntologyWithProtege.java   
private boolean showAxiomsDialog() {

        JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this.editor);
        AxiomsDialog dialog = new AxiomsDialog(this, topFrame);

        if (dialog.isClickedOK()) {
            selectedAxioms = dialog.getSelectedAxioms();
            if (!selectedAxioms.isEmpty()) {
                for (OWLAxiom axiom : selectedAxioms) {
                    changes.add(new AddAxiom(activeOntology, axiom));
                }
                return true;
            } else {
                editor.status("Selected Axioms is empty. Nothing to integrate.");
            }
        } else {
            editor.status("");
        }
        return false;
    }
项目:OWLAx    文件:IntegrateOntologyWithProtege.java   
private boolean commitDeclarations() {
    // editor.status("Integrating Declaration axioms with Protege ");
    if (declarationAxioms != null && !declarationAxioms.isEmpty()) {
        // declarationAxioms
        List<OWLOntologyChange> declarations = new ArrayList<OWLOntologyChange>();
        for (OWLAxiom declarationAxiom : declarationAxioms) {

            declarations.add(new AddAxiom(activeOntology, declarationAxiom));

        }
        ChangeApplied changeResult = owlOntologyManager.applyChanges(declarations);
        if (changeResult == ChangeApplied.SUCCESSFULLY) {
            editor.status("Declaration axioms integrated with protege successfully.");
            return true;
        } else if (changeResult == ChangeApplied.UNSUCCESSFULLY) {
            editor.status("Declaration integration with Protege unsuccessfull.");
            return false;
        } else if (changeResult == ChangeApplied.NO_OPERATION) {
            editor.status(
                    "Declaration axioms are duplicate. Possible reason: trying to create new OWL Entity which IRI match with existing OWLEntity IRI.");
            return false;
        }
    } else {

        editor.status("");
        return false;
    }

    return false;
}
项目: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;
}
项目:pronto    文件:PKBXMLSerializer.java   
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox,
                                        OWLOntologyManager manager, OWLDataFactory  factory) {

    ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory); 

    for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) {

        OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create(Constants.CERTAINTY_ANNOTATION_URI ));
        OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
        OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );   
        OWLClassExpression clsEv = (OWLClassExpression)converter.convert( cc.getEvidence() );
        OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
        OWLAxiom axiom = factory.getOWLSubClassOfAxiom( clsEv, clsCn, Collections.singleton( annotation ) );

        try {

            manager.applyChange( new AddAxiom(ontology, axiom) );

        } catch( OWLOntologyChangeException e ) {

            e.printStackTrace();
        }
    }
}
项目:logmap-matcher    文件:OntologyLoader.java   
public void addDummyAxiom2Ontology(){

    OWLClass dummycls = dataFactory.getOWLClass(IRI.create("http://logmap.cs.ox.ac.uk/ontologies#TopClass"));


    managerOnto.applyChange(                
            new AddAxiom(
                    onto, 
                    dataFactory.getOWLDeclarationAxiom(dummycls)));


    managerOnto.applyChange(                
            new AddAxiom(
                    onto, 
                    dataFactory.getOWLSubClassOfAxiom(
                            dummycls,
                            dataFactory.getOWLThing())));
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addClassMapping2Output(String iri1, String iri2, int dir_mapping, double conf) {    

    if (dir_mapping==LogMap_Lite.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createEquivalenceMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)))));
    }
    else if (dir_mapping==LogMap_Lite.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubClassOfMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)))));
    }
    else{ //if (dir_mapping==LogMap_Lite.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperClassOfMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)))));
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addDataPropMapping2Output(String iri1, String iri2, int dir_mapping, double conf) { 

    if (dir_mapping==LogMap_Lite.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createDataPropertyEquivalenceMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)))));
    }
    else if (dir_mapping==LogMap_Lite.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubDataPropertyMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)))));
    }
    else{ //if (dir_mapping==LogMap_Lite.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperDataPropertyMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)))));
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addObjPropMapping2Output(String iri1, String iri2, int dir_mapping, double conf) {  

    if (dir_mapping==LogMap_Lite.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createObjectPropertyEquivalenceMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)))));
    }
    else if (dir_mapping==LogMap_Lite.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubObjectPropertyMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)))));
    }
    else{ //if (dir_mapping==LogMap_Lite.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperObjectPropertyMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)))));
    }
}
项目:logmap-matcher    文件:ModuleExtractorManager.java   
/**
 * Necessary toi construct a module for an arbitriary set of axioms
 * @param moduleAxioms
 * @param moduleUri
 * @return
 */
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {

    OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();

    OWLOntology module=null;

    try {
        module = ontologyManager.createOntology(moduleIri);
        List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
        for(OWLAxiom axiom : moduleAxioms) {
            ontoChanges.add(new AddAxiom(module, axiom));
        }
        ontologyManager.applyChanges(ontoChanges);
    }

    catch(Exception e) {
        System.out.println("Error creating module ontology from extende set of axioms.");

    }

    //System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);

    return module;
}
项目:owltools    文件:TableToAxiomConverter.java   
public void parse(File myFile) throws IOException {
    try (BufferedReader reader = new BufferedReader(new FileReader(myFile))) {
        for(String line : IOUtils.readLines(reader)) {
            String[] row = line.split("\t");
            if (config.defaultCol1 != null)
                row[0] = config.defaultCol1;
            if (config.defaultCol2 != null) {
                String[] row2 = new String[2];
                row2[0] = row[0];
                row = row2;
                row[1] = config.defaultCol2;
            }
            addRow(row);
        }
    }

    if (config.individualsType != null) {
        OWLDataFactory df = graph.getDataFactory();
        graph.getManager().applyChange(new AddAxiom(graph.getSourceOntology(), 
                df.getOWLDeclarationAxiom(config.individualsType)));
    }

}
项目:archonte    文件:ArchonteUtils.java   
/** Adding the set annotations to the entity from the given ontology using the given manager.
 * @param modelManager
 * @param currentEntity
 * @param ontology
 * @param annotations
 */
public static void addAnnotation(OWLModelManager modelManager,
        OWLEntity currentEntity,
        OWLOntology ontology,
        Set<OWLAnnotation> annotations) {

    OWLDataFactory factory = modelManager.getOWLDataFactory();

    List<OWLOntologyChange> changes = new Vector<OWLOntologyChange>();
    for(OWLAnnotation annot : annotations) {
        OWLAxiom axiom = factory.getOWLAnnotationAssertionAxiom(
                currentEntity.getIRI(), 
                annot);
        changes.add(new AddAxiom(ontology, axiom));
    }
    modelManager.applyChanges(changes);
}
项目:gate-semano    文件:OntologyUtil.java   
/**
 * @param manager
 * @param ontology
 * @param newOwlAxiom
 */
public static void insertAxiomIntoOntology(
        OWLOntologyManager manager,
        OWLOntology ontology, OWLAxiom newOwlAxiom) {
    try {
        if (newOwlAxiom != null) {
            AddAxiom addAxiom = new AddAxiom(ontology,
                    newOwlAxiom);
            if (addAxiom != null) {
                manager.applyChange(addAxiom);
            }
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:owlbuilder    文件:Participant.java   
private OWLObject generateDependentOWLIndividual(Owlbuilder builder,
        PropertyTerm childProperty,
        OWLIndividual headInd,
        OWLObject childObject,
        Map<String,OWLObject> names) throws Exception{
    final OWLDataFactory factory = builder.getDataFactory();
    OWLObjectProperty elementProperty = (OWLObjectProperty)childProperty.generateOWL(builder,names);
    log.info("Generated Individual reference: " + headInd);
    if (childObject != null){
        if (childObject instanceof OWLIndividual){
            OWLIndividual childIndividual = (OWLIndividual)childObject;
            OWLObjectPropertyAssertionAxiom assertion =
                    factory.getOWLObjectPropertyAssertionAxiom(elementProperty, headInd, childIndividual);
            // Finally, add the axiom to our ontology and save
            AddAxiom addAxiomChange = new AddAxiom(builder.getTarget(), assertion);
            builder.getOntologyManager().applyChange(addAxiomChange);
        }
        else {  //child is class expression?
            log.info("class child of individual");
        }

    }
    return headInd; //TODO finish implementing individual case
}
项目:ontocomplib    文件:ELIndividualContext.java   
/** 
 * Adds a given attribute to the attributes of this context, updates the 'local' set of objects.
 * @param attribute the attribute to be added
 * @return <code>true</code> if the <code>attribute</code> is successfully added
 * @throws IllegalAttributeException if the given attribute is already in the set of 
 * attributes
 */
@Override
public boolean addAttribute(OWLClass attribute) {
    boolean added = getAttributes().add(attribute);
    if (!added) {
        throw new IllegalAttributeException("Attribute " + attribute + " has already been added");
    }
    try {
        for (OWLNamedIndividual individual : getReasoner().getInstances(attribute, false).getFlattened()) {
            IndividualObject o = createIndividualObject(individual);
            o.getDescription().addAttribute(attribute);
            addObject(o);
        }
        // the CEL reasoner is being used
        // add new concept name for the complement of the added attribute
        OWLClass complementOfAttribute = ELIndividualObject.getComplement(getOntology(), attribute);
        // make them disjoint
        Set<OWLClass> disjoint = new HashSet<OWLClass>();
        disjoint.add(attribute);
        disjoint.add(complementOfAttribute);
        OWLDisjointClassesAxiom disjointnessAxiom = getFactory().getOWLDisjointClassesAxiom(disjoint);
        // create a new AddAxiom object
        AddAxiom addAxiom = new AddAxiom(getOntology(),disjointnessAxiom);
        getManager().applyChange(addAxiom);
        reClassifyOntology();
        //TODO
        // updateObjectDescriptions should be overridden for EL contexts
        updateObjectDescriptions(Constants.AFTER_MODIFICATION);
    }
    catch (OWLOntologyChangeException e) {
        e.printStackTrace();
        System.exit(-1);
    }
    return added;
}
项目:ontocomplib    文件:ClassAssertionChange.java   
public ClassAssertionChange(IndividualContext c, AddAxiom ch, OWLNamedIndividual o, OWLClass a,
        boolean complement) {
// public ClassAssertionChange(IndividualContext c, AddAxiom ch) {
    super(c,ch);
    object = o;
    attribute = a;
    complemented = complement;
}
项目:ontocomplib    文件:QuestionConfirmedAction.java   
/**
 * Adds the confirmed question to the set of implications of the context, adds the corresponing
 * axiom to the ontology, pushes the change to the history stack and continues exploration with 
 * the next premise computed by using the new set of implications.
 */
@Override
public void actionPerformed(ActionEvent e) {
    logger.info("Expert accepted implication: " + getQuestion());
    // first create the GCI
    OWLSubClassOfAxiom axiom = getContext().getFactory().getOWLSubClassOfAxiom(
            getContext().toOWLDescription(getQuestion().getPremise()),
            getContext().toOWLDescription(getQuestion().getConclusion()));
    // create a new AddAxiom object
    AddAxiom addAxiom = new AddAxiom(getContext().getOntology(),axiom);
    // apply the change
    try {
        // add the new implication to the base
        getContext().getImplications().add(getQuestion());
        // also to the KB as a GCI
        getContext().getManager().applyChange(addAxiom);
        getContext().getHistory().push(new NewSubClassAxiomChange(getContext(),getQuestion(),addAxiom));
        getContext().reClassifyOntology();
        // update objects, update object descriptions
        getContext().updateObjects(Constants.AFTER_MODIFICATION);
        getContext().updateObjectDescriptions(Constants.AFTER_MODIFICATION);
        getContext().continueExploration(getContext().getNextPremise(getQuestion().getPremise()));
    }
    catch (OWLOntologyChangeException x) {
        x.printStackTrace();
        System.exit(-1);
    }

}
项目:minerva    文件:CoreMolecularModelManager.java   
private OWLObjectPropertyAssertionAxiom modifyAnnotations(OWLObjectPropertyAssertionAxiom axiom, 
        Set<OWLAnnotation> replacement, 
        ModelContainer model, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    OWLDataFactory f = model.getOWLDataFactory();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(2);
    changes.add(new RemoveAxiom(ont, axiom));
    OWLObjectPropertyAssertionAxiom newAxiom = 
            f.getOWLObjectPropertyAssertionAxiom(axiom.getProperty(), axiom.getSubject(), axiom.getObject(), replacement);
    changes.add(new AddAxiom(ont, newAxiom));
    applyChanges(model, changes, metadata);
    return newAxiom;
}
项目:minerva    文件:CoreMolecularModelManager.java   
public void addAxiom(ModelContainer model, OWLAxiom axiom, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    List<OWLOntologyChange> changes = Collections.<OWLOntologyChange>singletonList(new AddAxiom(ont, axiom));
    synchronized (ont) {
        /*
         * all changes to the ontology are synchronized via the ontology object
         */
        applyChanges(model, ont.getOWLOntologyManager(), changes, metadata);    
    }
}
项目:minerva    文件:CoreMolecularModelManager.java   
void addAxioms(ModelContainer model, Set<? extends OWLAxiom> axioms, METADATA metadata) {
    OWLOntology ont = model.getAboxOntology();
    List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>(axioms.size());
    for(OWLAxiom axiom : axioms) {
        changes.add(new AddAxiom(ont, axiom));
    }
    synchronized (ont) {
        /*
         * all changes to the ontology are synchronized via the ontology object
         */
        applyChanges(model, ont.getOWLOntologyManager(), changes, 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());
}
项目:pronto    文件:PKBXMLSerializer.java   
protected void addPABoxConstraints(OWLOntology ontology, PABox pabox, KnowledgeBase kb,
                                        OWLOntologyManager manager, OWLDataFactory  factory) {

    ConceptConverter converter = new ConceptConverter(kb, factory);

    for (Map.Entry<ATermAppl, Set<ConditionalConstraint>> entry : pabox.getConstraintsMap().entrySet()) {

        for (ConditionalConstraint cc : entry.getValue()) {

            OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create( Constants.CERTAINTY_ANNOTATION_URI ));
            OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
            OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );   
            OWLIndividual indiv = factory.getOWLNamedIndividual( IRI.create( entry.getKey().getName()) );
            OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
            OWLAxiom axiom = factory.getOWLClassAssertionAxiom( clsCn, indiv, Collections.singleton( annotation ) );

            try {

                manager.applyChange( new AddAxiom(ontology, axiom) );

            } catch( OWLOntologyChangeException e ) {

                e.printStackTrace();
            }
        }
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addClassMapping2Output(String iri1, String iri2, int dir_mapping, double conf) {    

    if (dir_mapping==Utilities.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createEquivalenceMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "="))));
    }
    else if (dir_mapping==Utilities.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubClassOfMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "<"))));
    }
    else{ //if (dir_mapping==Utilities.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperClassOfMapping(
                        factory.getOWLClass(IRI.create(iri1)),
                        factory.getOWLClass(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, ">"))));
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addDataPropMapping2Output(String iri1, String iri2, int dir_mapping, double conf) { 

    if (dir_mapping==Utilities.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createDataPropertyEquivalenceMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "="))));
    }
    else if (dir_mapping==Utilities.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubDataPropertyMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "<"))));
    }
    else{ //if (dir_mapping==Utilities.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperDataPropertyMapping(
                        factory.getOWLDataProperty(IRI.create(iri1)),
                        factory.getOWLDataProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, ">"))));
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
/**
 * Creates OWL axioms for mapping and adds it to the list
 */
public void addObjPropMapping2Output(String iri1, String iri2, int dir_mapping, double conf) {  

    if (dir_mapping==Utilities.EQ){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createObjectPropertyEquivalenceMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "="))));
    }
    else if (dir_mapping==Utilities.L2R){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSubObjectPropertyMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, "<"))));
    }
    else{ //if (dir_mapping==Utilities.R2L){
        listAxioms2Add.add(new AddAxiom(
                mappingsOnto,
                createSuperObjectPropertyMapping(
                        factory.getOWLObjectProperty(IRI.create(iri1)),
                        factory.getOWLObjectProperty(IRI.create(iri2)),
                        getAnnotations4Axiom(iri1, iri2, conf, ">"))));
    }
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
public void addInstanceMapping2Output(String iri1, String iri2, double conf)  throws Exception {
    listAxioms2Add.add(new AddAxiom(
            mappingsOnto,
            createSameIndividualMapping(
                    factory.getOWLNamedIndividual(IRI.create(iri1)),
                    factory.getOWLNamedIndividual(IRI.create(iri2)),
                    getAnnotations4Axiom(iri1, iri2, conf, "="))));
}
项目:logmap-matcher    文件:OWLAlignmentFormat.java   
public void addInstanceMapping2Output(String iri1, String iri2, double conf)  throws Exception {
    listAxioms2Add.add(new AddAxiom(
            mappingsOnto,
            createSameIndividualMapping(
                    factory.getOWLNamedIndividual(IRI.create(iri1)),
                    factory.getOWLNamedIndividual(IRI.create(iri2))
                    )
            ));
}
项目:HermiT-android    文件:Reasoner.java   
public Set<OWLAxiom> getPendingAxiomAdditions() {
    Set<OWLAxiom> added = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : m_pendingChanges)
        if (change instanceof AddAxiom)
            added.add(change.getAxiom());
    return added;
}
项目:elk-reasoner    文件:OwlChangesLoaderFactory.java   
Set<OWLAxiom> getPendingAxiomAdditions() {
    Set<OWLAxiom> added = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : pendingChanges_) {
        if (change instanceof AddAxiom) {
            added.add(change.getAxiom());
        }
    }
    return added;
}
项目:Hermit_1.3.8_android    文件:Reasoner.java   
public Set<OWLAxiom> getPendingAxiomAdditions() {
    Set<OWLAxiom> added = new HashSet<OWLAxiom>();
    for (OWLOntologyChange change : m_pendingChanges)
        if (change instanceof AddAxiom)
            added.add(change.getAxiom());
    return added;
}
项目:owltools    文件:Similarity.java   
/**
 * translates similarity results into OWL Axioms and saves axioms into an OWL Ontology
 *
 * @param ont
 */
public void addResultsToOWLOntology(OWLOntology ont) {
    if (!isComparable)
        return;
    OWLGraphWrapper graph = simEngine.getGraph();
    for (OWLAxiom axiom: translateResultsToOWLAxioms()) {
        AddAxiom aa = new AddAxiom(ont, axiom);
        graph.getManager().applyChange(aa);
    }
}
项目:owltools    文件:TemplatedTransformer.java   
public Set<OWLOntologyChange> tr(OWLAxiom inAxiom, Mapping m) {
    Set<OWLOntologyChange> chgs = new HashSet<OWLOntologyChange>();
    boolean isModified = false;
    OWLAxiom newAxiom = null;
    if (inAxiom instanceof OWLEquivalentClassesAxiom) {
        OWLEquivalentClassesAxiom aa = (OWLEquivalentClassesAxiom)inAxiom;
        Set<OWLClassExpression> xs = new HashSet<OWLClassExpression>();
        for (OWLClassExpression x : aa.getClassExpressions()) {
            OWLClassExpression x2 = replace(x, m);
            if (x2 == null) {
                xs.add(x);
            }
            else {
                isModified = true;
                xs.add(x2);
                LOG.info("  TR : "+x+ " ---> "+x2);
            }
        }
        if (isModified) {
            newAxiom = getOWLDataFactory().getOWLEquivalentClassesAxiom(xs);
        }
    }
    if (isModified) {
        if (m.isReplace) {
            chgs.add(new RemoveAxiom(ontology, inAxiom));
        }
        chgs.add(new AddAxiom(ontology, newAxiom));
    }
    return chgs;

}
项目:owltools    文件:OWLGraphWrapperBasic.java   
public void mergeOntology(OWLOntology extOnt, LabelPolicy labelPolicy) throws OWLOntologyCreationException {
    OWLOntologyManager manager = getManager();
    LOG.info("Merging "+extOnt+" policy: "+labelPolicy);
    for (OWLAxiom axiom : extOnt.getAxioms()) {
        if (labelPolicy != LabelPolicy.ALLOW_DUPLICATES) {
            if (axiom instanceof OWLAnnotationAssertionAxiom) {
                OWLAnnotationAssertionAxiom aa = (OWLAnnotationAssertionAxiom)axiom;
                if (aa.getProperty().isLabel()) {
                    OWLAnnotationSubject subj = aa.getSubject();
                    if (subj instanceof IRI) {
                        Optional<OWLLiteral> label = null;
                        for (OWLAnnotationAssertionAxiom a1 : sourceOntology.getAnnotationAssertionAxioms(subj)) {
                            if (a1.getProperty().isLabel()) {
                                label = a1.getValue().asLiteral();
                            }
                        }
                        if (label != null && label.isPresent()) {
                               if (labelPolicy == LabelPolicy.PRESERVE_SOURCE) {
                                   LOG.info("Preserving existing label:" +subj+" "+label+" // ditching: "+axiom);
                                   continue;
                               }
                               if (labelPolicy == LabelPolicy.PRESERVE_EXT) {
                                   LOG.info("Replacing:" +subj+" "+label+" with: "+axiom);
                                   LOG.error("NOT IMPLEMENTED");
                               }
                        }
                    }
                }
            }
        }
        manager.applyChange(new AddAxiom(sourceOntology, axiom));
    }
    for (OWLImportsDeclaration oid: extOnt.getImportsDeclarations()) {
        manager.applyChange(new AddImport(sourceOntology, oid));
    }
    addCommentToOntology(sourceOntology, "Includes "+summarizeOntology(extOnt));
}
项目:owltools    文件:OWLGraphWrapperEdgeTest.java   
@Test
public void testEdgeCache() throws Exception {
    OWLGraphWrapper g = getGraph("graph/cache-test.obo");

    OWLOntology o = g.getSourceOntology();
    OWLOntologyManager m = o.getOWLOntologyManager();
    OWLDataFactory f = m.getOWLDataFactory();

    OWLClass orphan = g.getOWLClassByIdentifier("FOO:0004");
    OWLClass root = g.getOWLClassByIdentifier("FOO:0001");

    g.getEdgesBetween(orphan, root); //just to trigger the cache

    OWLSubClassOfAxiom ax = f.getOWLSubClassOfAxiom(orphan, root);
    AddAxiom addAx = new AddAxiom(o, ax);
    m.applyChange(addAx);

    Set<OWLGraphEdge> edges = g.getEdgesBetween(orphan, root);
    assertNotNull(edges);

    assertEquals(0, edges.size());

    g.clearCachedEdges(); // test clear cache method

    edges = g.getEdgesBetween(orphan, root);
    assertNotNull(edges);

    assertEquals(1, edges.size());
}
项目:owltools    文件:OboOntologyReleaseRunner.java   
private void addAxiom(String info, OWLAxiom ax, OWLOntology ont, OWLOntologyManager manager, OWLDataFactory factory, List<String> reasonerReportLines) {
    if (oortConfig.isUseIsInferred()) {
        ax = AxiomAnnotationTools.markAsInferredAxiom(ax, factory);
    }
    manager.applyChange(new AddAxiom(ont, ax));
    String ppax = owlpp.render(ax);
    String rptLine = info+"\t"+ppax;
    reasonerReportLines.add(rptLine);
}
项目:relex    文件:OWLView.java   
/**
* Print out RelEx relations. All relations shown
* in a binary form.
*
* Example:
*       _subj(throw, John)
*       _obj(throw, ball)
*       tense(throw, past)
*       definite-FLAG(ball, T)
*       noun_number(ball, singular)
*/
public void printRelations(ParsedSentence parse, String sentence, int sentence_id, String ontologyname)
{
    try
    {
        sent = sentence;

        //Add the sentence to Sentence Class
        this.sentence_id = sentence_id;
        sentenceInd = factory.getOWLNamedIndividual(IRI.create(ontologyURI + "#" + "sentence_" + sentence_id));
        //OWLAnnotationProperty p = new OWLAnnotationPropertyImpl(IRI.create(sentence));

        //OWLAnnotation label = factory.getOWLAnnotation(sentence);
        OWLOntologyFormat ontologyFormat = manager.getOntologyFormat(ontology);
        OWLAnnotation label = (OWLAnnotation) factory.getOWLAnnotationProperty(sentence, (PrefixManager) ontologyFormat);

        OWLClassAssertionAxiom sentClass = factory.getOWLClassAssertionAxiom(this.sentence,sentenceInd);
        OWLAnnotationAssertionAxiom labelClass = factory.getOWLAnnotationAssertionAxiom((OWLAnnotationSubject) sentClass, label);
        manager.applyChange(new AddAxiom(ontology, sentClass));
        manager.applyChange(new AddAxiom(ontology, labelClass));

        printRelations(parse, null);

    }
    catch (OWLOntologyChangeException ex)
    {
        Logger.getLogger(OWLView.class.getName()).log(Level.SEVERE, null, ex);
    }
}
项目:gate-semano    文件:OntologyParser.java   
/**
 * used by the plugin itself
 * stores the annotation value in the ontology manager, so that the next time the ontology is flushed, the annotation value is written into the file.
 *
 * @param av AnnotationValue
 */
public void addAnnotationPropertyValue(AnnotationValue av) {
    try {
        OWLEntity entityClass = getEntity(av.getAnnotatedEntity());
        OWLOntology o = entities2Ontologies.get(entityClass);
        if (o != null && entityClass != null) {
            Set<OWLAnnotationProperty> uris = getAnnotationPropertyUris(av.getAnnotationProperty());
            OWLDataFactory f = manager.getOWLDataFactory();
            OWLLiteral litValue = f.getOWLTypedLiteral(av.formatMetaData());
            for (OWLAnnotationProperty u : uris) {
                // do not store the same value several times:
                boolean found = false;
                for (OWLAnnotation a : entityClass.getAnnotations(o, u)) {

                    if ((new AnnotationValue(u.getIRI()
                            .toString(), entityClass.getIRI().toString(), a.getValue().toString())).contentEquals(av)) {
                        found = true;
                    }
                }
                if (!found) {
                    OWLAnnotation annotation = f.getOWLAnnotation(u, litValue);
                    OWLAnnotationAxiom ax = f.getOWLAnnotationAssertionAxiom(entityClass
                            .getIRI(), annotation);
                    manager.applyChange(new AddAxiom(o, ax));
                    modifiedOntologies.add(o);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

}