以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  [求助]怎样理解这个文件http://www.w3.org/1999/02/22-rdf-syntax-ns  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=86090)


--  作者:dorothyle
--  发布时间:8/5/2010 11:39:00 AM

--  [求助]怎样理解这个文件http://www.w3.org/1999/02/22-rdf-syntax-ns
我把这个文件下载到机器上,用Protege打开,我能看出这是一个关于定义RDF词汇的本体文件。但是我真的不明白这个定义是做什么用的?在每一个RDF文件的开头,都有一个<rdf:RDF>这样的标签,这个标签是为了声明XML namespace的吗?
    我打开这个本体文件后,看Active Ontology上写的是这些:
    
此主题相关图片如下:
按此在新窗口浏览图片
我的翻译是:
题目:RDF词汇表
描述: RDF 命名空间定义的RDF词汇的RDF图表(Schema这个词在这里我不知道当什么讲)
  这个文件的作用到底是什么呢?


    第二个问题,下面这幅图里的这些类都是起什么作用的呢?

此主题相关图片如下:
按此在新窗口浏览图片


     第三个问题,这些对象属性是用于描述类之间的关系,我现在的理解就是一个陈述里的主语,谓语,以及宾语之间的关系,对吗?但是first, rest,value又都代表什么呢?
    
此主题相关图片如下:
按此在新窗口浏览图片


我一直没特别明白这个命名空间,我现在理解就是在定义一个本体时,需要指定一个IRI,并且本体里所有的类,属性都有一个固定的IRI,所以在万维网上搜索的时候,每个资源都有一个唯一的标识符,这样的理解对吗?
    请各位高手予以指点吧。谢谢!


--  作者:dorothyle
--  发布时间:8/5/2010 11:58:00 AM

--  
同时,还有一个问题,就是RDF/XML文件里的这个内容怎样理解:
<!-- This is a comment.-->,这个comment在这里怎样翻译呢?是“注解”的意思吗?
--  作者:dorothyle
--  发布时间:8/5/2010 12:04:00 PM

--  
以上我问的这些问题是不是属于XML部分的内容啊?
--  作者:dorothyle
--  发布时间:8/9/2010 9:47:00 AM

--  
以上内容我明白了,第一个问题是ontology header,我现在的理解就是一个本体自身的一个描述,也可以看作是一个资源,其中说明了该本体的一些诸如名称等内容,在定义一个本体的header的时候,有一些固定的属性,其中包括:
rdfs:label
rdfs:comment,关于资源的注解
rdfs:versionInfo,关于本体的版本
rdfs:seeAlso,提供了一个可以参考地址的网站,不经常使用
rdfs:isDefinedBy,用于说明描述该本体的另一个资源
--  作者:dorothyle
--  发布时间:8/9/2010 9:51:00 AM

--  
第二个问题和第三个问题都是关于rdf的语法规则,RDF采用“陈述”的方式描述信息,这符合人类的阅读习惯和语法规则。RDF网页上或本体中的所有概念都视为“资源”,每个资源都有自己的唯一的URI予以标识,以确保每个资源在万维网的范围内都是可以被定位,被找到的。然后为资源之间创造关系,通过“属性”创造关系,让这些资源联系起来。一个陈述包括主,谓,宾三个部分。主语可以是资源,谓语是属性,而宾语可以是资源也可以是常量。因此,一个陈述也可以被叫作“三元组”,因为每个陈述都由三个部分组成,即主,谓,宾。
然后,RDF将所有的资源以及资源之间的关系以图的方式展现出来。在一幅RDF图中,椭圆形表示资源,通常是主语或宾语;带箭头的线表示属性,通过表示谓语;矩形表示常量,通过是宾语。以图的方式表示资源之间的关系直观,容得理解。但是图是对资源的抽象表示,要想让应用程序用上这些信息,就要将图转换为具有一定格式的代码,这样程序才能真正对信息进行操作。所以就要对RDF进行序列化,也就是完成抽象模型与具体格式之间的转换,这就叫RDF Serialization。
对RDF转换有多种格式,其中常用的有RDF/XML,Terse RDF Triple Language(Turtle),以及N-三元组。每一种格式都有自己的语法规则,对图的转换最终形成的代码是不一样的,其中Turtle最简洁的一种。
RDF在对信息进行集成的时候,创建了一些结构,比如容器,列表等,可以将信息组合在一起。
RDF提供三种容器,rdf:Bag, rdf:Seq, rdf:Alt,其中rdf:Bag中的资源不要求顺序,rdf:Seq中的资源要求有顺序,rdf:Alt中的资源可以无序,在描述一套相等的概念时使RDF Lists将资源的集合组合在一起,这样一旦RDF图被组合在一起,这些集合里的内容就不能再做变更了。
以上关于RDF结构的内容都在RDF的相关语法里介绍了,其具体地址是:
http://www.w3.org/1999/02/22-rdf-syntax-ns#
用。

--  作者:Lexxuan
--  发布时间:8/9/2010 10:52:00 PM

--  
支持LZ的自学和分享

学习XML,RDF,OWL,弄懂namespace的含义和用法是一个基础而关键的问题。其实楼主在4楼所查到的固定属性个人认为了解一下就可以了,深入方向是怎么定义和书写自己的XML,RDF,OWL
建议LZ多了解以后,不懂的话发些实际问题上来大家交流交流


--  作者:dorothyle
--  发布时间:8/11/2010 11:51:00 AM

--  
看了Lexxuan回复的帖子,很受启发,刚才刚刚看完《Semantic Web Programming》的第五章,感觉又摸不着头脑了,第五章介绍了推理机的使用,当构建了一个本体以后,针对该本体进行推理,也就是找出这个本体的“语义”,推理的级别有很多种,第一种不使用任何推理,只是对本体中已经存在的陈述进行真实地复述;第二种使用rdfs进行推理,那么则可以得到rdfs语法的推理结果,第三种使用owl语法进行推理,这三种级别推理得到的结果是完全不同。
    这些是进行推理的源代码:
package net.semwebprogramming.chapter5.PelletReasoning;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Iterator;

import org.mindswap.pellet.jena.PelletReasonerFactory;

import com.hp.hpl.jena.ontology.Individual;
import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.ontology.OntModelSpec;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.reasoner.Reasoner;
import com.hp.hpl.jena.reasoner.ValidityReport;
import com.hp.hpl.jena.util.iterator.ExtendedIterator;

public class InferenceExample
{
   /**
    * This program takes 4 parameters an input file name
    * an output file name an input file format a reasoning
    * level {RDFS, OWL-DL}
    */
   public static void main(String[] args)
   {
    //validate the program arguments
      if(args.length != 4)
      {   
         System.err.println("Usage: java InferenceExample "
            + "<input file> <input format> <output file> "
            + "<none|rdfs|owl>");
         return;
      }

      String inputFileName = args[0];
      String inputFileFormat = args[1];
      String outputFileName = args[2];
      String reasoningLevel = args[3];

      //create an input stream for the input file
      FileInputStream inputStream = null;
      PrintWriter writer = null;
      try
      {
         inputStream = new FileInputStream(inputFileName);
      } catch (FileNotFoundException e) {
         System.err.println("'" + inputFileName
            + "' is an invalid input file.");
         return;
      }
      
      //create an output print writer for the results
      try
      {
         writer = new PrintWriter(outputFileName);
      } catch (FileNotFoundException e) {
         System.err.println("'" + outputFileName
            + "' is an invalid output file.");
         return;
      }
      
      //create the appropriate jena model
      OntModel model = null;
      if("none".equals(reasoningLevel.toLowerCase()))
      {
         /*
          * "none" is jena model with OWL_DL
          * ontologies loaded and no inference enabled
          */
         model = ModelFactory.createOntologyModel(
            OntModelSpec.OWL_DL_MEM);
      }
      else if("rdfs".equals(reasoningLevel.toLowerCase()))
      {
         /*
          * "rdfs" is jena model with OWL_DL
          * ontologies loaded and RDFS inference enabled
          */
         model = ModelFactory.createOntologyModel(
            OntModelSpec.OWL_DL_MEM_RDFS_INF);
      }
      else if("owl".equals(reasoningLevel.toLowerCase()))
      {
         /*
          * "owl" is jena model with OWL_DL ontologies
          * wrapped around a pellet-based inference model
          */
         Reasoner reasoner =
            PelletReasonerFactory.theInstance().create();
         Model infModel = ModelFactory.createInfModel(
            reasoner, ModelFactory.createDefaultModel());
         model = ModelFactory.createOntologyModel(
            OntModelSpec.OWL_DL_MEM, infModel);
      }
      else
      {
         //invalid inference setting
         System.err.println("Invalid inference setting, "
            + "choose one of <none|rdfs|owl>.");
         return;
      }
      
      //load the facts into the model
      model.read(inputStream, null, inputFileFormat);
      
      //validate the file
      ValidityReport validityReport = model.validate();
      if(validityReport != null && !validityReport.isValid())
      {
         Iterator i = validityReport.getReports();
         while(i.hasNext())
         {
            System.err.println(
               ((ValidityReport.Report)i.next()).getDescription());
         }
         return;
      }
      
      //Iterate over the individuals, print statements about them
      ExtendedIterator iIndividuals = model.listIndividuals();
      while(iIndividuals.hasNext())
      {
         Individual i = (Individual)iIndividuals.next();
         printIndividual(i, writer);
      }
      iIndividuals.close();
      
      writer.close();
      model.close();
   }
   
   /**
    * Print information about the individual
    * @param i The individual to output
    * @param writer The writer to which to output
    */
   public static void printIndividual(
      Individual i, PrintWriter writer)
   {
      //print the local name of the individual (to keep it terse)
      writer.println("Individual: " + i.getLocalName());
      
      //print the statements about this individual
      StmtIterator iProperties = i.listProperties();
      while(iProperties.hasNext())
      {
         Statement s = (Statement)iProperties.next();
         writer.println("  " + s.getPredicate().getLocalName()
            + " : " + s.getObject().toString());
      }
      iProperties.close();
      writer.println();
   }
}


--  作者:dorothyle
--  发布时间:8/11/2010 11:52:00 AM

--  
因为回复帖子不能发图片,我新开一个帖子帖出上段代码的运行结果
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
70.313ms