以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  请教:OntModel::createIndividual()  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=28906)


--  作者:xirufeng
--  发布时间:3/20/2006 10:46:00 AM

--  请教:OntModel::createIndividual()
在已经有的文件owl文件的基础上,执行createIndividual()后,为什么只可以保存最新的实例,而且并不能在owl文件中体现?
谢谢!
--  作者:jpz6311whu
--  发布时间:3/20/2006 10:49:00 AM

--  
你把完整的程序源代码和完整的owl文件贴出来,并说明运行结果。
--  作者:xirufeng
--  发布时间:3/20/2006 10:55:00 AM

--  
结果就是只能保存一次的结果
D:\make>javac createInstance.java

D:\make>java createInstance
Enter your resource:钢笔
input individualName:
英雄牌
the input individualName is:英雄牌
the property:discounts value=5.2
5.2
the property:usertype value=买

the property:pen_color value=红

the property:price value=25
25
the property:commodityname value=英雄牌钢笔
英雄牌钢笔
http://www.owl-ontologies.com/unnamed.owl#英雄牌

import java.util.Vector;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.*;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.reasoner.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.reasoner.rulesys.*;
import com.hp.hpl.jena.util.*;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.ontology.OntResource;


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Hashtable;
import java.util.List;
import java.util.ArrayList;
import java.io.DataInputStream;

public class createInstance
{
  public void instance()throws IOException
  {
    InputStreamReader reader = new InputStreamReader(System.in);
    BufferedReader input = new BufferedReader(reader);
    System.out.print("Enter your resource:");
    String res = input.readLine();
    OntModel model = ModelFactory.createOntologyModel();
    OntDocumentManager dm = model.getDocumentManager();
    dm.addAltEntry("http://protege.stanford.edu/plugins/owl/protege",
                   "file:/wyh/seller.owl");
    model.read("http://protege.stanford.edu/plugins/owl/protege");
    String sellerNS = "http://www.owl-ontologies.com/unnamed.owl#";
    OntClass resource = model.getOntClass(sellerNS + res);
    System.out.println("input individualName:");
    String individualName=input.readLine();
    System.out.println("the input individualName is:"+individualName);
    Individual createIndividual=model.createIndividual(sellerNS+individualName,resource);
    ExtendedIterator propertyIterator=resource.listDeclaredProperties();
    while(propertyIterator.hasNext())
    {
      OntProperty ontproperty1=model.getOntProperty(propertyIterator.next().toString());
      if(ontproperty1.isDatatypeProperty())
      {
        System.out.print("the property:"+ontproperty1.getLocalName()+" value=");
        String propertyValue=input.readLine();
        createIndividual.addProperty(ontproperty1,propertyValue);
        System.out.println(propertyValue);
      }
      else if(ontproperty1.isObjectProperty())
      {
        ExtendedIterator toClassProperty=null;
        OntClass toClass=null;
        if(ontproperty1.getLocalName().equals("book_author"))
        {
          toClass=model.getOntClass(sellerNS+"person");
          toClassProperty=toClass.listDeclaredProperties();
          while(toClassProperty.hasNext())
          {
          OntProperty ontproperty2=model.getOntProperty(
                                     toClassProperty.next().toString());
          System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
          String propertyValue=input.readLine();
          createIndividual.addProperty(ontproperty2,propertyValue);
          System.out.println(propertyValue);
          }

        }
        if(ontproperty1.getLocalName().equals("user"))
        {
          toClass=model.getOntClass(sellerNS+"person");
          toClassProperty=toClass.listDeclaredProperties();
          while(toClassProperty.hasNext())
          {
          OntProperty ontproperty2=model.getOntProperty(
                                     toClassProperty.next().toString());
          System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
          String propertyValue=input.readLine();
          createIndividual.addProperty(ontproperty2,propertyValue);
          System.out.println(propertyValue);
          }

        }
        else if(ontproperty1.getLocalName().equals("book_keywords"))
        {
          toClass=model.getOntClass(sellerNS+"book_content");
          toClassProperty=toClass.listDeclaredProperties();
          while(toClassProperty.hasNext())
          {
          OntProperty ontproperty2=model.getOntProperty(
                                     toClassProperty.next().toString());
          System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
          String propertyValue=input.readLine();
          createIndividual.addProperty(ontproperty2,propertyValue);
          System.out.println(propertyValue);
          }

        }
        else if(ontproperty1.getLocalName().equals("book_layout_rectangle"))
        {
          toClass=model.getOntClass(sellerNS+"book_rectangle_info");
          toClassProperty=toClass.listDeclaredProperties();
          while(toClassProperty.hasNext())
          {
          OntProperty ontproperty2=model.getOntProperty(
                                     toClassProperty.next().toString());
          System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
          String propertyValue=input.readLine();
          createIndividual.addProperty(ontproperty2,propertyValue);
          System.out.println(propertyValue);
          }

        }
/*       toClassProperty=toClass.listDeclaredProperties();
        while(toClassProperty.hasNext())
        {
          OntProperty ontproperty2=model.getOntProperty(
                                     toClassProperty.next().toString());
          System.out.println("the property:"+ontproperty2.getLocalName()+"value=");
          String propertyValue=input.readLine();
          System.out.println(propertyValue);
        }*/
      }
    }
    Iterator listIndivi=resource.listInstances();
    while(listIndivi.hasNext())
    {
      System.out.println(listIndivi.next());
    }
  }
  public static void main(String[] arags)throws IOException
  {
    createInstance creInstance=new createInstance();
    creInstance.instance();
  }
}


--  作者:xirufeng
--  发布时间:3/20/2006 10:58:00 AM

--  
下次再这样创建一个之后,上次的http://www.owl-ontologies.com/unnamed.owl#英雄牌 就不显示了
--  作者:jpz6311whu
--  发布时间:3/20/2006 11:21:00 AM

--  
你在程序中创建新的本体实例,并对实例添加属性。
但是这些操作都是在内存中进行的,如果要把数据持久化,还需要把本体库写回到文件中:
Writing RDF
Jena has methods for reading and writing RDF as XML. These can be used to save an RDF model to a file and later read it back in again.

Tutorial 3 created a model and wrote it out in triple form. Tutorial 4 modifies tutorial 3 to write the model in RDF XML form to the standard output stream. The code again, is very simple: model.write can take an OutputStream argument.

// now write the model in XML form to a file
model.write(System.out);The output should look something like this:

<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
>
  <rdf:Description rdf:about='http://somewhere/JohnSmith'>
    <vcard:FN>John Smith</vcard:FN>
    <vcard:N rdf:nodeID="A0"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="A0">
    <vcard:Given>John</vcard:Given>
    <vcard:Family>Smith</vcard:Family>
  </rdf:Description>
</rdf:RDF>
The RDF specifications specify how to represent RDF as XML. The RDF XML syntax is quite complex. The reader is referred to the primer being developed by the RDFCore WG for a more detailed introduction. However, let's take a quick look at how to interpret the above.

RDF is usually embedded in an <rdf:RDF> element. The element is optional if there are other ways of know that some XML is RDF, but it is usually present. The RDF element defines the two namespaces used in the document. There is then an <rdf:Description> element which describes the resource whose URI is "http://somewhere/JohnSmith". If the rdf:about attribute was missing, this element would represent a blank node.

The <vcard:FN> element describes a property of the resource. The property name is the "FN" in the vcard namespace. RDF converts this to a URI reference by concatenating the URI reference for the namespace prefix and "FN", the local name part of the name. This gives a URI reference of "http://www.w3.org/2001/vcard-rdf/3.0#FN". The value of the property is the literal "John Smith".

The <vcard:N> element is a resource. In this case the resource is represented by a relative URI reference. RDF converts this to an absolute URI reference by concatenating it with the base URI of the current document.

There is an error in this RDF XML; it does not exactly represent the Model we created. The blank node in the Model has been given a URI reference. It is no longer blank. The RDF/XML syntax is not capable of representing all RDF Models; for example it cannot represent a blank node which is the object of two statements. The 'dumb' writer we used to write this RDF/XML makes no attempt to write correctly the subset of Models which can be written correctly. It gives a URI to each blank node, making it no longer blank.

Jena has an extensible interface which allows new writers for different serialization languages for RDF to be easily plugged in. The above call invoked the standard 'dumb' writer. Jena also includes a more sophisticated RDF/XML writer which can be invoked by specifying another argument to the write() method call:

// now write the model in XML form to a file
model.write(System.out, "RDF/XML-ABBREV");
This writer, the so called PrettyWriter, takes advantage of features of the RDF/XML abbreviated syntax to write a Model more compactly. It is also able to preserve blank nodes where that is possible. It is however, not suitable for writing very large Models, as its performance is unlikely to be acceptable. To write large files and preserve blank nodes, write in N-Triples format:

// now write the model in XML form to a file
model.write(System.out, "N-TRIPLE");
  This will produce output similar to that of tutorial 3 which conforms to the N-Triples specification.


--  作者:xirufeng
--  发布时间:3/20/2006 3:23:00 PM

--  
非常感谢!
--  作者:xirufeng
--  发布时间:3/22/2006 9:38:00 AM

--  
我按照上边介绍的做了,还是一样,真不明白是怎么回事

以下是引用jpz6311whu在2006-3-20 11:21:00的发言:
你在程序中创建新的本体实例,并对实例添加属性。
但是这些操作都是在内存中进行的,如果要把数据持久化,还需要把本体库写回到文件中:
Writing RDF
Jena has methods for reading and writing RDF as XML. These can be used to save an RDF model to a file and later read it back in again.

Tutorial 3 created a model and wrote it out in triple form. Tutorial 4 modifies tutorial 3 to write the model in RDF XML form to the standard output stream. The code again, is very simple: model.write can take an OutputStream argument.

// now write the model in XML form to a file
model.write(System.out);The output should look something like this:

<rdf:RDF
   xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
   xmlns:vcard='http://www.w3.org/2001/vcard-rdf/3.0#'
  >
   <rdf:Description rdf:about='http://somewhere/JohnSmith'>
     <vcard:FN>John Smith</vcard:FN>
     <vcard:N rdf:nodeID="A0"/>
   </rdf:Description>
   <rdf:Description rdf:nodeID="A0">
     <vcard:Given>John</vcard:Given>
     <vcard:Family>Smith</vcard:Family>
   </rdf:Description>
</rdf:RDF>
The RDF specifications specify how to represent RDF as XML. The RDF XML syntax is quite complex. The reader is referred to the primer being developed by the RDFCore WG for a more detailed introduction. However, let's take a quick look at how to interpret the above.

RDF is usually embedded in an <rdf:RDF> element. The element is optional if there are other ways of know that some XML is RDF, but it is usually present. The RDF element defines the two namespaces used in the document. There is then an <rdf:Description> element which describes the resource whose URI is "http://somewhere/JohnSmith". If the rdf:about attribute was missing, this element would represent a blank node.

The <vcard:FN> element describes a property of the resource. The property name is the "FN" in the vcard namespace. RDF converts this to a URI reference by concatenating the URI reference for the namespace prefix and "FN", the local name part of the name. This gives a URI reference of "http://www.w3.org/2001/vcard-rdf/3.0#FN". The value of the property is the literal "John Smith".

The <vcard:N> element is a resource. In this case the resource is represented by a relative URI reference. RDF converts this to an absolute URI reference by concatenating it with the base URI of the current document.

There is an error in this RDF XML; it does not exactly represent the Model we created. The blank node in the Model has been given a URI reference. It is no longer blank. The RDF/XML syntax is not capable of representing all RDF Models; for example it cannot represent a blank node which is the object of two statements. The 'dumb' writer we used to write this RDF/XML makes no attempt to write correctly the subset of Models which can be written correctly. It gives a URI to each blank node, making it no longer blank.

Jena has an extensible interface which allows new writers for different serialization languages for RDF to be easily plugged in. The above call invoked the standard 'dumb' writer. Jena also includes a more sophisticated RDF/XML writer which can be invoked by specifying another argument to the write() method call:

// now write the model in XML form to a file
model.write(System.out, "RDF/XML-ABBREV");
  This writer, the so called PrettyWriter, takes advantage of features of the RDF/XML abbreviated syntax to write a Model more compactly. It is also able to preserve blank nodes where that is possible. It is however, not suitable for writing very large Models, as its performance is unlikely to be acceptable. To write large files and preserve blank nodes, write in N-Triples format:

// now write the model in XML form to a file
model.write(System.out, "N-TRIPLE");
   This will produce output similar to that of tutorial 3 which conforms to the N-Triples specification.




--  作者:jpz6311whu
--  发布时间:3/22/2006 10:12:00 AM

--  
你把完整的程序源代码和完整的owl文件贴出来,并说明运行结果。
--  作者:xirufeng
--  发布时间:3/23/2006 8:40:00 AM

--  
方法一:下边红色字体另外加的,这样的话,还是只能保存一次。
方法二:如果自己定义outputstream的话,能编译,但不能运行。定义如下:
          File file=new File("d:/wyh/seller.owl");
          FileOutputStream out=new FileOutputStream(file);
          model.write(out);   
异常如下:
Exception in thread "main" com.hp.hpl.jena.rdf.arp.ParseException: {E301} Premat
ure end of file.
        at com.hp.hpl.jena.rdf.arp.ARPFilter.parseWarning(ARPFilter.java:559)
        at com.hp.hpl.jena.rdf.arp.ARPFilter.parseWarning(ARPFilter.java:552)
        at com.hp.hpl.jena.rdf.arp.ParserSupport.saxException(ParserSupport.java
:179)
        at com.hp.hpl.jena.rdf.arp.RDFParser.saxEx(RDFParser.java:260)
        at com.hp.hpl.jena.rdf.arp.RDFParser.oneWhite(RDFParser.java:248)
        at com.hp.hpl.jena.rdf.arp.RDFParser.whiteOrErr(RDFParser.java:196)
        at com.hp.hpl.jena.rdf.arp.RDFParser.rdfFile(RDFParser.java:98)
        at com.hp.hpl.jena.rdf.arp.ARPFilter.parse(ARPFilter.java:314)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:221)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:209)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:261)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:206)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:189
4)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:184
6)
        at createInstance.instance(createInstance.java:41)
        at createInstance.main(createInstance.java:144)
com.hp.hpl.jena.shared.JenaException: rethrew: {E301} Premature end of file.
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:226)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:209)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:261)
        at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:206)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:189
4)
        at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:184
6)
        at createInstance.instance(createInstance.java:41)
        at createInstance.main(createInstance.java:144)
Caused by: com.hp.hpl.jena.rdf.arp.ParseException: {E301} Premature end of file.

        at com.hp.hpl.jena.rdf.arp.ARPFilter.parseWarning(ARPFilter.java:559)
        at com.hp.hpl.jena.rdf.arp.ARPFilter.parseWarning(ARPFilter.java:552)
        at com.hp.hpl.jena.rdf.arp.ParserSupport.saxException(ParserSupport.java
:179)
        at com.hp.hpl.jena.rdf.arp.RDFParser.saxEx(RDFParser.java:260)
        at com.hp.hpl.jena.rdf.arp.RDFParser.oneWhite(RDFParser.java:248)
        at com.hp.hpl.jena.rdf.arp.RDFParser.whiteOrErr(RDFParser.java:196)
        at com.hp.hpl.jena.rdf.arp.RDFParser.rdfFile(RDFParser.java:98)
        at com.hp.hpl.jena.rdf.arp.ARPFilter.parse(ARPFilter.java:314)
        at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:221)
        ... 7 more
以下是引用xirufeng在2006-3-20 10:55:00的发言:
结果就是只能保存一次的结果
D:\make>javac createInstance.java

D:\make>java createInstance
Enter your resource:钢笔
input individualName:
英雄牌
the input individualName is:英雄牌
the property:discounts value=5.2
5.2
the property:usertype value=买

the property:pen_color value=红

the property:price value=25
25
the property:commodityname value=英雄牌钢笔
英雄牌钢笔
http://www.owl-ontologies.com/unnamed.owl#英雄牌

import java.util.Vector;
import com.hp.hpl.jena.rdf.model.*;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.*;
import com.hp.hpl.jena.ontology.*;
import com.hp.hpl.jena.reasoner.*;
import com.hp.hpl.jena.vocabulary.*;
import com.hp.hpl.jena.reasoner.rulesys.*;
import com.hp.hpl.jena.util.*;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;
import com.hp.hpl.jena.ontology.OntProperty;
import com.hp.hpl.jena.ontology.OntResource;


import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Hashtable;
import java.util.List;
import java.util.ArrayList;
import java.io.DataInputStream;

public class createInstance
{
   public void instance()throws IOException
   {
     InputStreamReader reader = new InputStreamReader(System.in);
     BufferedReader input = new BufferedReader(reader);
     System.out.print("Enter your resource:");
     String res = input.readLine();
     OntModel model = ModelFactory.createOntologyModel();
     OntDocumentManager dm = model.getDocumentManager();
     dm.addAltEntry("http://protege.stanford.edu/plugins/owl/protege",
                    "file:/wyh/seller.owl");
     model.read("http://protege.stanford.edu/plugins/owl/protege");
     String sellerNS = "http://www.owl-ontologies.com/unnamed.owl#";
     OntClass resource = model.getOntClass(sellerNS + res);
     System.out.println("input individualName:");
     String individualName=input.readLine();
     System.out.println("the input individualName is:"+individualName);
     Individual createIndividual=model.createIndividual(sellerNS+individualName,resource);
     ExtendedIterator propertyIterator=resource.listDeclaredProperties();
     while(propertyIterator.hasNext())
     {
       OntProperty ontproperty1=model.getOntProperty(propertyIterator.next().toString());
       if(ontproperty1.isDatatypeProperty())
       {
         System.out.print("the property:"+ontproperty1.getLocalName()+" value=");
         String propertyValue=input.readLine();
         createIndividual.addProperty(ontproperty1,propertyValue);
         System.out.println(propertyValue);
       }
       else if(ontproperty1.isObjectProperty())
       {
         ExtendedIterator toClassProperty=null;
         OntClass toClass=null;
         if(ontproperty1.getLocalName().equals("book_author"))
         {
           toClass=model.getOntClass(sellerNS+"person");
           toClassProperty=toClass.listDeclaredProperties();
           while(toClassProperty.hasNext())
           {
           OntProperty ontproperty2=model.getOntProperty(
                                      toClassProperty.next().toString());
           System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
           String propertyValue=input.readLine();
           createIndividual.addProperty(ontproperty2,propertyValue);
           System.out.println(propertyValue);
           }

         }
         if(ontproperty1.getLocalName().equals("user"))
         {
           toClass=model.getOntClass(sellerNS+"person");
           toClassProperty=toClass.listDeclaredProperties();
           while(toClassProperty.hasNext())
           {
           OntProperty ontproperty2=model.getOntProperty(
                                      toClassProperty.next().toString());
           System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
           String propertyValue=input.readLine();
           createIndividual.addProperty(ontproperty2,propertyValue);
           System.out.println(propertyValue);
           }

         }
         else if(ontproperty1.getLocalName().equals("book_keywords"))
         {
           toClass=model.getOntClass(sellerNS+"book_content");
           toClassProperty=toClass.listDeclaredProperties();
           while(toClassProperty.hasNext())
           {
           OntProperty ontproperty2=model.getOntProperty(
                                      toClassProperty.next().toString());
           System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
           String propertyValue=input.readLine();
           createIndividual.addProperty(ontproperty2,propertyValue);
           System.out.println(propertyValue);
           }

         }
         else if(ontproperty1.getLocalName().equals("book_layout_rectangle"))
         {
           toClass=model.getOntClass(sellerNS+"book_rectangle_info");
           toClassProperty=toClass.listDeclaredProperties();
           while(toClassProperty.hasNext())
           {
           OntProperty ontproperty2=model.getOntProperty(
                                      toClassProperty.next().toString());
           System.out.print("the property:"+ontproperty2.getLocalName()+" value=");
           String propertyValue=input.readLine();
           createIndividual.addProperty(ontproperty2,propertyValue);
           System.out.println(propertyValue);
           }

         }
  /*       toClassProperty=toClass.listDeclaredProperties();
         while(toClassProperty.hasNext())
         {
           OntProperty ontproperty2=model.getOntProperty(
                                      toClassProperty.next().toString());
           System.out.println("the property:"+ontproperty2.getLocalName()+"value=");
           String propertyValue=input.readLine();
           System.out.println(propertyValue);
         }*/
       }
     }
     model.write(System.out);
     Iterator listIndivi=resource.listInstances();
     while(listIndivi.hasNext())
     {
       System.out.println(listIndivi.next());
     }
   }
   public static void main(String[] arags)throws IOException
   {
     createInstance creInstance=new createInstance();
     creInstance.instance();
   }
}




--  作者:jpz6311whu
--  发布时间:3/23/2006 2:18:00 PM

--  
你看看报错的地方:
at createInstance.instance(createInstance.java:41)
并不是write出错了,是在这个之前的read就有错
--  作者:xirufeng
--  发布时间:3/25/2006 7:07:00 PM

--  
那为什么我不写的话,就能读出来
还能识别我输入的类概念是不是本体中的类概念,这个不证明我的read是对的么?
以下是引用jpz6311whu在2006-3-23 14:18:00的发言:
你看看报错的地方:
at createInstance.instance(createInstance.java:41)
并不是write出错了,是在这个之前的read就有错


--  作者:jpz6311whu
--  发布时间:3/25/2006 7:53:00 PM

--  
at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:184
6)
        at createInstance.instance(createInstance.java:41)
        at createInstance.main(createInstance.java:144)
很明显,没有能够完成读的操作,在解析的时候就出错了,
“识别我输入的类概念”,这个 更是不可能的
--  作者:xirufeng
--  发布时间:3/26/2006 10:42:00 AM

--  
这是读操作的代码,当时显示树形式的时候也是这样读的
    OntModel model = ModelFactory.createOntologyModel();
    OntDocumentManager dm = model.getDocumentManager();
    dm.addAltEntry("http://protege.stanford.edu/plugins/owl/protege",
                   "file:/wyh/seller.owl");
    model.read("http://protege.stanford.edu/plugins/owl/protege");

有错吗?

以下是引用jpz6311whu在2006-3-25 19:53:00的发言:
at com.hp.hpl.jena.ontology.impl.OntModelImpl.read(OntModelImpl.java:184
6)
         at createInstance.instance(createInstance.java:41)
         at createInstance.main(createInstance.java:144)
很明显,没有能够完成读的操作,在解析的时候就出错了,
“识别我输入的类概念”,这个 更是不可能的


--  作者:jpz6311whu
--  发布时间:3/26/2006 12:35:00 PM

--  
有可能不是程序错了,而是owl数据有错
--  作者:fyfunny
--  发布时间:3/26/2006 11:41:00 PM

--  
楼上的朋友,能提供owl文件代码吗,我把程序拷下来执行,有错误,是不是owl文件不一样啊,我要用owl做毕设,也和楼主的问题差不多
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
140.625ms