Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-owl] regarding insertion of swrl rules through api

sandeep gadi gadisandeep at gmail.com
Sat Feb 14 13:19:52 PST 2009


Hi,

I am using protege 3.4 and whne I am trying to run the program to insert
swrl rules through api I am getting it inserted in my owl file but not in
this way                      hasAge(?p,56)-> sqwrl:select(?p)  but rather
this way hasAge(?p, 56)  ∧  sqwrl:select(?p) →   can anybody tell me why?

thank you
sandy

import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.Collection;

import com.hp.hpl.jena.util.FileUtils;

 import edu.stanford.smi.protege.model.Cls;
 import edu.stanford.smi.protegex.owl.ProtegeOWL;
 import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
 import edu.stanford.smi.protegex.owl.model.OWLDatatypeProperty;
 import edu.stanford.smi.protegex.owl.model.OWLObjectProperty;
import edu.stanford.smi.protegex.owl.model.RDFIndividual;
import edu.stanford.smi.protegex.owl.jena.JenaOWLModel;
import edu.stanford.smi.protegex.owl.model.RDFSClass;
import edu.stanford.smi.protegex.owl.swrl.model.SWRLFactory;
import edu.stanford.smi.protegex.owl.swrl.model.SWRLImp;
import edu.stanford.smi.protegex.owl.swrl.parser.SWRLParseException;
import edu.stanford.smi.protegex.owl.swrl.sqwrl.SQWRLQueryEngine;
import edu.stanford.smi.protegex.owl.swrl.sqwrl.SQWRLQueryEngineFactory;


 public class JenaDemo {

    /**
     * @param args the command line arguments
     * @throws SWRLParseException
     */


    public static void main(String[] args) throws SWRLParseException {

        JenaOWLModel owlModel = null;


        try {

            File file = new File("sap.owl");
            owlModel =
ProtegeOWL.createJenaOWLModelFromURI(file.toURI().toString());


        }
        catch (Exception e) {
            e.printStackTrace();
        }

           SWRLFactory factory = new SWRLFactory(owlModel);

        SWRLImp imp = factory.createImp("Query-3", "hasAge(?p,56)->
sqwrl:select(?p)");

        Collection col = imp.getReferencedInstances();
        System.out.println("elements: "+col.toString());

        //System.out.println(imp);
        String fileName = "sap.owl";
        Collection errors = new ArrayList();
        owlModel.save(new File(fileName).toURI(), FileUtils.langXMLAbbrev,
errors);
        System.out.println("File saved with " + errors.size() + " errors.");



    }

 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.stanford.edu/pipermail/protege-owl/attachments/20090214/f72e8229/attachment.html>


More information about the protege-owl mailing list