Skip to Content
学习 SPARQL,第 2 版
book

学习 SPARQL,第 2 版

by Bob DuCharme
July 2025
Beginner to intermediate
386 pages
5h 25m
Chinese
O'Reilly Media, Inc.
Content preview from 学习 SPARQL,第 2 版

第9章RDF 模式、OWL 和推理

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

第 2 章中,我们了解了 RDF 模式 (RDFS) 和网络本体语言 (OWL) 在 RDF 应用程序中的基本作用:

  • RDFS 和 OWL 是 W3C 标准词汇表,可用于定义和描述数据集的三元组可能使用的类和属性。它们并不像其他数据建模系统中的模式那样作为数据必须遵守的模板,而是作为额外的元数据,帮助您从数据中获得更多信息。

  • RDFS 和 OWL 语句本身使用三元组表示,因此可以使用 SPARQL 进行查询。

  • RDFS 和 OWL 词汇表中的属性和类可以让你描述自己的属性和类,从而让某些应用程序从你的数据集中推断出新的信息。例如,如果有一个三元组指定ab:spouse 属性为owl:SymmetricProperty ,而另一个三元组告诉我们 Richard 的ab:spouse 值为 Cindy,那么了解owl:SymmetricProperty含义的应用程序就会知道 Cindy 的ab:spouse 值为 Richard。这就是元数据价值的一个典型例子:元数据增加了有关数据的信息,从而让你可以从数据中获得更多信息。

什么样的应用程序能理解owl:SymmetricProperty 的含义,或者rdfs:domainrdfs:range 等 RDFS 属性的含义?这又是如何扩展 SPARQL 查询功能的?我们将在本章中了解这些问题的答案,内容包括

什么是推理?

推断 "一词有很多含义,但在我们谈论 RDF 时却有非常特殊的含义。

SPARQL和RDFS推理

如何将 SPARQL 技能与能执行 RDFS 推断的应用程序(即能理解 RDFS 词汇表术语(如rdfs:domain )的应用程序)结合起来,从数据中获取更多信息?

SPARQL和OWL推理

如何将 SPARQL 技能与可以执行 OWL 推断的应用程序结合使用,从而从数据中获取更多信息?

使用 SPARQL 进行推理

SPARQL 本身就可以进行一些推理,这为您处理数据的方式增加了灵活性。

查询模式

SPARQL 查询如何为你提供更多有关 RDFS 和 OWL 模式和本体的信息。

什么是推理?

韦氏新世界大学词典》将 "推断 "定义为 "从已知或假设的事物中得出结论或决定"。在进行 RDF 推断 时,现有的三元组就是 "已知事物",而推理工具将从中推理出新的三元组。(这些新的三元组可能会让你得出某种结论或决定,这取决于你的应用程序如何处理它们)。

第 2 章中,我们举例说明了两个文件如何协同工作来实现这种推理。第一个文件中有一些关于理查德-穆特的三元组数据:

# filename: ex045.ttl

@prefix ab: <http://learningsparql.com/ns/addressbook#> .

ab:i0432 ab:firstName     "Richard" ;
        ab:lastName       "Mutt" ;
        ab:postalCode     "49345" ;
        ab:city           "Springfield" ;
        ab:homeTel        "(229) 276-5135" ;
        ab:streetAddress  "32 Main St." ;
        ab:region         "Connecticut" ;         
        ab:email          "richard49@hotmail.com" ;
        ab:playsInstrument ab:vacuumCleaner .

第二个文件中的三元组告诉我们更多关于

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

向量数据库 (Chinese Edition)

向量数据库 (Chinese Edition)

Nitin Borwankar
Python文本分析

Python文本分析

Jens Albrecht, Sidharth Ramachandran, Christian Winkler

Publisher Resources

ISBN: 9798341663039