记录一些杂事

2010年1月8日

惠普实验室停止支持JENA开发
HPLabs management have decided not to continue with an active programme of Semantic Web research at HPL. Members of the Semantic Web research group are moving to other roles, both inside and outside HP: please consult personal blogs and similar sources for revised contact details.

The Jena platform and associated development projects remain open source under the liberal BSD-style license. With HP’s support, we are in the process of transferring ownership of the copyright of the code from HP to a commercially neutral body. There is no change for individuals or companies using Jena, and the move will make it easier to continue and expand the core developer community. Indeed it will enable us to accept contributions more easily. Many current members of the Jena team will remain involved in further enhancements to the Jena codebase, and supporting the user community via the jena-dev email list. The Jena source code remains at SourceForge, and the new web address for Jena is www.openjena.org.

We would like to thank all of the various research groups, customers, Jena users and individual contributors we have worked with over the years as we have built the Jena platform to its current state. We look forwards to future enhancements to Jena’s capability, and to helping to create other exciting developments in Semantic Web technologies and products.

The HP Semantic Web Team – October 2009

同样,2009年8月,http://www.co-ode.org/blog/ 上面宣布CO-ODE工程宣告结束:

After several extensions and ripping through many different project members the CO-ODE project has finally reached the end (sob).

We think it has been very successful:

1、Protege 4 is now in very good shape and is fully released
2、Loads of plugins are available and we’ve got some brilliant contributions from the community
3、Tutorials shall continue to come out of Manchester on a regular basis
4、Protege 4.1 is in its early stages, but already available as a preview to be taken on by Stanford
5、Lots of people can now say they are ontology engineers

Thankyou to all the people involved. And thankyou to JISC for funding the project.

Now, I’m off for a break from ontologies for a few months(!)

Nick (and the rest of the former CO-ODE team)

斯坦福的WEB版本体编辑器WebProtege越做越强,未来将会向面向服务架构靠拢

NTK 2.3 Pre-Release全面支持OWL 2,基于OWL-API开发

大杂烩

OWL 2 词汇全貌

2010年1月6日

首先介绍4个OWL 2词汇需要用到的预定义命名空间

  • rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
  • rdfs: http://www.w3.org/2000/01/rdf-schema#
  • owl: http://www.w3.org/2002/07/owl#
  • xsd: http://www.w3.org/2001/XMLSchema#

定义类,有以下几种方式:
1.直接取名字,这是用的最多的方法
用RDF/XML-ABBREV语法表达如下:
<owl:Class rdf:about=”#crab”/>

2.集合类,通过几种类组合创造出一个新的类
比如:有一个类,它是“女人”和“有孩子的”这2个类取交集,所得到的类(这个类可以等价于“母亲”)
用RDF/XML-ABBREV语法表达如下:
<owl:Class rdf:about=”#母亲”>
 <owl:equivalentClass>
  <owl:Class>
  <owl:intersectionOf rdf:parseType=”Collection”>
   <rdf:Description rdf:about=”#女人” />
   <owl:Restriction>
   <owl:onProperty rdf:resource=”#有孩子” />
   <owl:someValuesFrom rdf:resource=”#人” />
   </owl:Restriction>
  </owl:intersectionOf>
  </owl:Class>
 </owl:equivalentClass>
</owl:Class>

上面介绍的是owl:intersectionOf,它代表交集,所有的集合表达方式如下:
_:x owl:intersectionOf ( C1 … Cn ). 交集 protege中使用“and”
_:x owl:unionOf ( C1 … Cn ). 并集 protege中使用“or”
_:x owl:complementOf C. 补集 并集 protege中使用“not”

3.枚举类,通过一系列的个体(individual)所描绘的一种类
比如:“文一美食店”这个类,是由很多在文一路的美食店所组成的一个类
  <owl:Class rdf:about=”#饭店”/>
  <owl:Class rdf:about=”#文一美食店”>
    <owl:oneOf rdf:parseType=”Collection”>
      <j.0:饭店 rdf:about=”#半亩地”/>
      <j.0:饭店 rdf:about=”#一席地”/>
      <j.0:饭店 rdf:about=”#老山东牛杂”/>
    </owl:oneOf>
  </owl:Class>
需要注意的是,该类并非由其他类所构成,而是由一系列的个体(individual)构成,语法如下:
_:x owl:oneOf ( a1 … an ). protege中使用 {}

4.限制类,这个翻译来源于Object(Datatype) Property Restrictions,这种定义类的方式听起来很别扭,但在现实生活中确实需要如此去表达,比如:很富有的人、有2个孩子的父亲,这些都是可以表达成类的。看一个用RDF/XML-ABBREV语法表达的例子:
  <owl:Class rdf:about=”#奶茶店”>
    <owl:equivalentClass>
      <owl:Restriction>
        <owl:someValuesFrom>
          <owl:Class rdf:about=”#奶茶”/>
        </owl:someValuesFrom>
        <owl:onProperty rdf:resource=”#出售”/>
      </owl:Restriction>
    </owl:equivalentClass>
  </owl:Class>

上面需要表达的意思:奶茶店等价于这样的一个类,这个类叫“出售一些奶茶的”。对于现实中的例子就是,奶茶店是卖奶茶的。在这里,我们发现,“出售一些奶茶的”这本身就是一种类,这种类就是所谓的限制类。限制类的定义方法有很多,在JENA中,我们会发现OntClass有一个子接口Restriction,而Restriction接口下面又衍生出

  1. SomeValuesFromRestriction
  2. AllValuesFromRestriction
  3. HasValueRestriction
  4. MaxCardinalityQRestriction
  5. MinCardinalityQRestriction
  6. CardinalityQRestriction
  7. MaxCardinalityRestriction
  8. MinCardinalityRestriction
  9. CardinalityRestriction

我们逐一解释:
1、已经介绍了
2、这家奶茶店只卖奶茶,出售这个属性所跟的所有个体全部属于奶茶(AllValuesFrom)
关于SomeValuesFrom和AllValuesFrom有很多话题可以聊,具体看其他文章
3、这个和前面2者不同,前面2者属性后面需要跟,而这个属性后面必须跟个体,出售拿破仑戒指的古董店,拿破仑戒指是戒指一个个体,不是一个类,这里把有出售拿破仑戒指的这些古董店合起来称为一个类
4、最多出售一种品牌的店叫专卖店
5、最少有两家分店的店可以叫做连锁店
6、精确的定义到数字
7、8、9和4、5、6非常类似,区别在于,属性后面可以不跟,4、5、6是OWL 2新增的内容

另外,OWL 2又多了一种限制类,叫做ObjectHasSelf,具有自反性质,比如:爱自己的人可以称为自恋的人,这个在protege和jena里面都还没有实现。上面9个方式可以基于Object Property来描述的,同样也可以基于Data Property来描述。不过OWL-API分的跟细致,将Object Property Restrictions和Data Property Restrictions分开实现了,有新兴趣的朋友可以去比较比较。

语义网基础

年初杂谈

2010年1月5日

人,活着,为了什么?
每天都在摆摊卖水果的女人可能为了养活孩子
单位打工的白领可能为了买房、结婚、生子
富裕的人可能为了更多的消遣
立志的人可能为了理想
如果我们用5WHY法则画出鱼骨头,估计归根到底就是人的欲望,说破烂点,就是贪欲,说本质点,就是动物本能。
如果欲望达到了预期的目标,人会开心,会惬意,会去共享,会去文化传承,物质始终会枯竭,只有文化生生不息,文化激发更多的欲望,欲望灿烂出更多的文化。

人,活着,为什么要害怕?
可能因为自身的脆弱,所以会在别人还没有攻击之前,已有了防人意识
可能因为害怕失去,所以会在还没有失去之前拼命捍卫
可能因为达不到目标,所以会无意识将目标砍掉或者虚设

人,活着,为什么要攀比?
可能因为自身触手可及却偏偏没有得到的那份心有不甘
可能因为自身的口德行德激发了他人的欲望
可能因为要发泄压抑已久的欲望

如果将上面那些垃圾言论全部净化,独善其身,大彻大悟,玩转人生,可谓心胸海纳百川之人

=================无语的分割线=====================

什么是本体?

这是哲学的概念……GHJT@#T^#@&*!@!UIGJHJ
某某老外发言……&*@……#IUGH#HG!GIU#Y#*7

话说当年上帝害怕通天塔,于是让人们有了不同的语言,不同的思维,不同的个性,于是,通天塔倒了

人们只有使用统一的语言,才能相互交流,只有使用同一种概念,才能对一个事物达成共识

本体,就是这样的一种工具,让领域与领域之间的人们对一个事物达成共识

如果大家都运用本体对万事万物进行建模,通过相互沟通,达成一致,最终将这些数据朝贡给造物主,那么造物主将会通晓万事万物,如果他愿意为人们提供服务,那么他的脑子就是语义网

终有一天,通天塔再次完工,但这次,人们的本能可能会毁了这一切……

大杂烩

用jena api来理解RDF——三元组

2010年1月1日

JENA中有一个最底层的接口:RDFNode,它代表RDF这张巨大图中的节点,这个节点可以是一个资源,可以是一个字符窜或者数字。因此它对应与2个子接口:
interface Literal extends RDFNode
interface Resource extends RDFNode
Literal接口代表了一些原始类型节点,比如:32位整型、布尔型等等。
Resource接口还可以继续衍生出2个重要的接口:
interface Container extends Resource
interface Property extends Resource
Container接口就对应了RDF的容器表达能力,里面有bag,seq,alt
Property接口就是所谓的资源属性了

在RDF的世界中,其实描述资源只有一种方式,那就是三元组,包括:主体(subject),谓词(predicate),客体(object)。主体和客体就是图中的2个节点,谓词就是一条边。这三元组在JENA中用Statement接口来描述,该接口中有下面3个方法:
public Resource getSubject();
public Property getPredicate();
public RDFNode getObject();

我们可以发现,主体一定是一种资源,不可能是一个Literal原始类型,因此主体必定属于Resource接口实现,但是客体可以是原始类型,比如:人有2条腿。为主体;为谓词;2为客体。

用一个例子来巩固下:

  1. <?xml version="1.0"?>
  2.  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  3.           xmlns:s="http://example.org/students/vocab#">
  4.  
  5.     <rdf:Description rdf:about="http://example.org/courses/6.001">
  6.        <s:students>
  7.           <rdf:Bag>
  8.              <rdf:li rdf:resource="http://example.org/students/Amy"/>
  9.              <rdf:li rdf:resource="http://example.org/students/Mohamed"/>
  10.              <rdf:li rdf:resource="http://example.org/students/Johann"/>
  11.              <rdf:li rdf:resource="http://example.org/students/Maria"/>
  12.              <rdf:li rdf:resource="http://example.org/students/Phuong"/>
  13.           </rdf:Bag>
  14.        </s:students>
  15.     </rdf:Description>
  16.  </rdf:RDF>

如果要一下子看出这个RDF中有几个三元组,一定不是很方便吧?如果用图来表示:
201001011021
是不是非常清晰呢?图中有一个主体http://example.org/courses/6.001,它有一条边http://example.org/students/vocab#students,对应的客体就是那个空节点。同理还有这个空节点所对应的那些三元组。用JENA来解析这个例子:

  1. Model model = ModelFactory.createDefaultModel();
  2.  
  3. model.read(new FileInputStream("student.rdf"), null);
  4.  
  5. StmtIterator  it = model.listStatements();
  6.  
  7. while(it.hasNext())
  8. {
  9.     System.out.println(it.next());
  10. }

打印的结果如下:
[http://example.org/courses/6.001, http://example.org/students/vocab#students, -23ba78ea:125e9da42c8:-8000]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#_5, http://example.org/students/Phuong]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#_4, http://example.org/students/Maria]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#_3, http://example.org/students/Johann]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#_2, http://example.org/students/Mohamed]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#_1, http://example.org/students/Amy]
[-23ba78ea:125e9da42c8:-8000, http://www.w3.org/1999/02/22-rdf-syntax-ns#type, http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag]

JENA, 语义网基础 ,

用jena api来理解RDF——空节点

2009年12月26日

在RDF入门的例子中,有这样一幅图:
200912262132
最中间的那个节点起一个过渡作用,这时,虽然它也是一个资源,但这个资源没有必要标上资源描述符,因为它可能只在应用程序局部使用,作为推理机的一个桥梁等等作用,换句说,这个资源别人没有必要去引用。这样的节点,我们称之为空节点:

  1. Model model = ModelFactory.createDefaultModel();
  2.  
  3.   Resource blankNode = model.createResource(new AnonId("tempNode"));
  4.   Property city = model.createProperty("http://www.crabobe.com/city");
  5.   Property street = model.createProperty("http://www.crabobe.com/street");
  6.   blankNode.addProperty(city, "深圳");
  7.   blankNode.addProperty(street, "龙岗");
  8.  
  9.   Resource crab = model.createResource("http://www.crabobe.com/crab");
  10.   Property address = model.createProperty("http://www.crabobe.com/address");
  11.   crab.addProperty(address, blankNode);
  12.  
  13.   model.write(System.out);

注意,包含中文的源码文件必须是UTF-8的,运行结果如下:

  1. <rdf:RDF
  2.     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  3.     xmlns:j.0="http://www.crabobe.com/" > 
  4.   <rdf:Description rdf:about="http://www.crabobe.com/crab">
  5.     <j.0:address rdf:nodeID="A0"/>
  6.   </rdf:Description>
  7.   <rdf:Description rdf:nodeID="A0">
  8.     <j.0:street>龙岗</j.0:street>
  9.     <j.0:city>深圳</j.0:city>
  10.   </rdf:Description>
  11. </rdf:RDF>

JENA, 语义网基础 , , ,