本体更新

时间:2013-12-30 07:03:51

标签: java owl protege

我已经安装了Protege 4.2 alpha来创建Ontology。我创建了一个本体论(Tamil.owl)。我需要使用java程序更新创建的本体。

执行以下java程序时出现错误,指出“无协议”

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();
}
}

如何解决以下错误?

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

其他输出是:

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>

0 个答案:

没有答案