0

I have installed Protege 4.2 alpha for creating Ontology. I have created an ontology (Tamil.owl). My need is to update the created ontology using a java program.

Got an error stating "no protocol" while executing the below java program

import java.io.File;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.URI;
import java.util.Collection;
import java.util.Iterator;

import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.ObjectProperty;
import com.hp.hpl.jena.ontology.OntClass;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.util.FileManager;

import edu.stanford.smi.protegex.owl.model.OWLIndividual;
import edu.stanford.smi.protegex.owl.model.OWLNamedClass;
import edu.stanford.smi.protegex.owl.swrl.bridge.OWLSubClassAxiom;

public class addIndividual {

public static void main(String args[]) throws Exception
{
    //create an empty model
    OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_TRANS_INF, null);


    InputStream in = FileManager.get().open("/home/saranya/workspace/New/plugins/edu/stanford/smi/protegex/owl/tamil.owl");
    if (in == null) {
       // throw new IllegalArgumentException("File not found");
    }

    // read the RDF/XML file
    model.read(in, "");

    String NS = "http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owl";
    //String NSS = "http://www.semanticweb.org/ontologies/2013/3/untitled-ontology-4.owl/Crops#";
    OntClass att = model.getOntClass(NS + "Crops");
    //Individual I1 = model.createIndividual(NS + "Rice", att);
    System.out.println("Test NS"+NS);
    //OntClass att2 = model.getOntClass(NS + "Pest");
    //System.out.println(att2);
    //Individual I2 = model.createIndividual(NS + "Worm", att);
    OntClass att1 = model.createClass(NS + "TestClass");
    OntClass att2 = model.createClass(NS + "NewTest");
    OntClass att22 = model.createClass(NS + "பழம்");

    ObjectProperty prop = model.createObjectProperty(NS +"is_a");
    Property prop1 = model.createDatatypeProperty(NS +"has_a");
    OntClass myClass = model.createClass(NS + "மாம்பழம்");
    myClass.addSuperClass(att22);
    myClass.addSubClass(att1);
    //model.add(I2, prop, I1);

    model.write(System.out);

    PrintStream p= new PrintStream("/home/saranya/workspace/New/plugins/edu/stanford/smi/protegex/owl/Tamil.owl");
    model.write(p);
    p.close();
}
}

How to resolve the below error??

ERROR [main] (RDFDefaultErrorHandler.java:40) - unknown-source: {E213} no protocol:

Other output is:

Test NShttp://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owl
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" > 
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlபழம்">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlNewTest">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlis_a">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#ObjectProperty"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlhas_a">
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlTestClass">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlமாம்பழம்"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlமாம்பழம்">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/saranya/ontologies/2013/11/Ontology1.owlபழம்"/>
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#Class"/>
  </rdf:Description>
</rdf:RDF>
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Is there a good reason you're not just doing `model.read( "/home/saranya/workspace/New/plugins/edu/stanford/smi/protegex/owl/tamil.owl" );`? (Also, it looks like you're storing your ontology _in_ the Protégé distribution. I don't know whether that would affect this code, but it seems like it must be bad practice.) – Joshua Taylor Dec 30 '13 at 19:08
  • Also, it looks like your model was updated successfully. What's in the file before you read its contents? – Joshua Taylor Dec 30 '13 at 19:12
  • On a different topic, why 4.2 alpha? That's old, over a year I think. Use 4.3 instead. It's not relevant to this question but I'd not recommend starting with an alpha version. – Ignazio Dec 30 '13 at 21:04

0 Answers0