Freebase Data Dump结构初探
来源:互联网 发布:单片机烧录软件 编辑:程序博客网 时间:2024/05/01 16:40
最近要做知识库相关的东西,于是就有机会认识一下Freebase。
从官网上下载了30G的Data Dump,有些不知该怎么使用,于是花了许多天了解。
首先简单说一下Freebase是什么,Freebase乍看上去类似Wikipedia,可以在上面浏览到许多信息条目,其成员可以在上面进行条目创作。与Wikipedia不同的是,Freebase采用结构化的数据形式,而Wikipedia则不是。第一次认识Freebase后,发现Freebase已经关闭了,只能通过Data Dump来认识它了。
Freebase Data Dump格式
目前,Freebase官网提供N-Triple RDF格式的数据压缩包的下载,整个压缩包30G,解压后300G+。下载后,可以用压缩软件解压,也可以通过编程工具(比如Java的GzipInuputStream)边读取边解压。
解压后发现数据按行组织,每一行都是一个三元组(恩,一行一个Triple):
下面举个例子:
<http://rdf.freebase.com/ns/m.0qjjmlt> <http://rdf.freebase.com/ns/type.object.name> “川浦正大”@ja .从左至右依次是Subject(主语)、Predicate(谓词)、Object(“宾语”或者“客体")
w3c上对RDF格式是这样解释的[1]:
the subject, which is an IRI or a blank node the predicate, which is an IRI the object, which is an IRI, a literal or a blank node
简单来说,就是主语可以是一个IRI或者是blank node,谓词可以是一个IRI,宾语可以是IRI、blanknode、或者文字。
关于IRI是什么,其全称是Internationalized Resource Identifiers,即国际化资源定位符,可以认为是扩展的URI,不仅可以使用英文,Unicode字符集都可以使用。[2]
至于文字(Literal),w3c给出的例子如下[3]:
<http://example.org/show/218> <http://www.w3.org/2000/01/rdf-schema#label> "That Seventies Show"^^<http://www.w3.org/2001/XMLSchema#string> . # literal with XML Schema string datatype<http://example.org/show/218> <http://www.w3.org/2000/01/rdf-schema#label> "That Seventies Show" . # same as above<http://example.org/show/218> <http://example.org/show/localName> "That Seventies Show"@en . # literal with a language tag<http://example.org/show/218> <http://example.org/show/localName> "Cette Série des Années Septante"@fr-be . # literal outside of ASCII range with a region subtag<http://example.org/#spiderman> <http://example.org/text> "This is a multi-line\nliteral with many quotes (\"\"\"\"\")\nand two apostrophes ('')." .<http://en.wikipedia.org/wiki/Helium> <http://example.org/elements/atomicNumber> "2"^^<http://www.w3.org/2001/XMLSchema#integer> . # xsd:integer<http://en.wikipedia.org/wiki/Helium> <http://example.org/elements/specificGravity> "1.663E-4"^^<http://www.w3.org/2001/XMLSchema#double> . # xsd:double这些三元组的最后一元都是文字,可以看到有一部分文字后面有^^,其后跟随的是一个IRI(dataType IRI),表示该文字的类型(identifying a datatype that determines how the lexical form maps to a literal value[1]),有一部分后面有@,其后跟随的是文字的语言(language tag).
网址[3]中还给出了RDF triple扩展的巴科斯范式的文法,最近刚刚学习编译原理也是倍由亲切感,有兴趣的朋友可以点击文末的链接看,为了有一个形象的认识,这里仅贴非终结符部分:
[1] ntriplesDoc ::= triple? (EOL triple)* EOL?[2] triple ::= subject predicate object '.'[3] subject ::= IRIREF | BLANK_NODE_LABEL[4] predicate ::= IRIREF[5] object ::= IRIREF | BLANK_NODE_LABEL | literal[6] literal ::= STRING_LITERAL_QUOTE ('^^' IRIREF | LANGTAG)?
Freebase数据结构:
先来简单了解一下Freebase数据结构:
整个Freebase数据库是一张大图,每个结点都使用type/object定义,边使用type/link定义。
每个条目称之为一个Topic,一个Topic往往由很多属性。比如对于某一个人,可能有姓名、性别、出生日期、个人经历、职业等等属性。
不同的Topic分属不同的type,一个Type下的topic,其属性类型往往是大致相同的。比如"姚明",在Freebase库中的MID是m.01jzhl,在数据库中有条目(忽略前缀):
<m.01jzhl> <type.object.type> <people.person>与<person.person>相关的,它在freebase中有这样的条目:
<m.01jzhl><people.person.profession><m.01445t>.<m.01jzhl><people.person.date_of_birth>"1980-09-12"^^<http://www.w3.org/2001/XMLSchema#date>.<m.01jzhl><people.person.education><m.0n1k91v>.<m.01jzhl><people.person.profession><m.02h664x>.<m.01jzhl><people.person.nationality><m.0d05w3>.<m.01jzhl><people.person.parents><m.0g5bnz5>.<m.01jzhl><people.person.place_of_birth><m.06wjf>.<m.01jzhl><people.person.spouse_s><m.0j688yq>.<m.01jzhl><people.person.parents><m.0g5bnyy>.<m.01jzhl><people.person.gender><m.05zppz>.<m.01jzhl><people.person.weight_kg>"141.0".再比如,姚明还是一位运动员:
<m.01jzhl><type.object.type><sports.pro_athlete>.与运动员相关的,他有如下条目:
<sports.pro_athlete><type.type.instance><m.01jzhl>.<m.01jzhl><sports.pro_athlete.teams><m.0j_ny44>.<m.01jzhl><sports.pro_athlete.teams><m.0j2m__w>.<m.01jzhl><sports.pro_athlete.teams><m.0t_6b7s>.<m.01jzhl><type.object.type><sports.pro_athlete>.<m.01jzhl><sports.pro_athlete.career_start>"1997"^^<http://www.w3.org/2001/XMLSchema#gYear>.<m.01jzhl><sports.pro_athlete.sports_played_professionally><m.0c55c2z>.<m.01jzhl><sports.pro_athlete.teams><m.0j_ny44>.<m.01jzhl><sports.pro_athlete.teams><m.0j2m__w>.<m.01jzhl><sports.pro_athlete.teams><m.0t_6b7s>.<m.01jzhl><sports.pro_athlete.sports_played_professionally><m.0c55c2z>.
同时,多个type属于一个domain,这就构成了domain->type->topic这样的三级关系。
Freebase属性
这里还搞的不是很懂,具体可参考[5],里面谈论了很多和Freebase属性相关的问题。
参考文献:
[1]w3c RDF1,1 Concept https://www.w3.org/TR/rdf11-concepts/#section-triples
[2]IRI 百度百科 http://baike.baidu.com/item/iri
[3]RDF 1.1 N-Triples:https://www.w3.org/TR/n-triples/
[4]Basic Concepts:http://developers.google.com/freebase/guide/basic_concepts
[5]Freebase.com语义数据库浅析 http://blog.sina.com.cn/s/blog_600791e00100hd4m.html
同时再附两篇博客:
Freebase 介绍:http://www.ruanyifeng.com/blog/2007/05/freebase_com.html
Freebase再研究 http://www.ruanyifeng.com/blog/2008/04/freebase_reloaded.html
- Freebase Data Dump结构初探
- Freebase Data Dump 结构初探(二)——浅析元信息
- 初探Freebase和Wikidata的转换
- dump data
- oracle data dump
- data dump for sequence
- Data Block Dump
- oracle data dump
- 【论文笔记】Information Extraction over Structured Data: Question Answering with Freebase
- FreeBase介绍
- FreeBase介绍
- 数据块结构 (dump)
- Dump Table Data (T-SQL)
- dump vxlan internal data structures
- Spring-data-jpa 初探
- Android Data Binding 初探
- linux gdb 调试core dump初探
- freebase使用总结
- H264编码器
- python3.x安装ipython notebook
- HashMap与HashTable
- 视频压缩编码的基本原理
- 文件版本管理器
- Freebase Data Dump结构初探
- 我的web前端自学之路-心得篇:我为什么要学习web前端?
- CAVLC基于上下文自适应的可变长编码
- 最小公倍数(LCM)与最大公约数(GCD)
- CABAC基于上下文的自适应二进制熵编码
- 笔试题8
- CodeForces - 762A k-th divisor
- 第七届蓝桥杯大赛个人赛省赛(软件类)
- 快速沃尔什变化(FWT)介绍