RDF中的三元组重复,权威性观点? [英] Duplicate triple in RDF, authoritative view?

查看:245
本文介绍了RDF中的三元组重复,权威性观点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果三元组存储区包含相同的三元组的两倍,那么关于此冗余的权威立场是什么(如果有的话)?

if a triple store contains twice the same triple, what is (if any exist) the authoritative position about this redundancy ?

另外,是否应允许三元组在同一上下文中存储相同的三元组的两倍?

Additionally, should a triplestore be allowed to store twice the same triple within the same context ?

我之所以这样问,是因为在rdflib中,您显然可以将相同的三元组存储两次(或更多).这是读者

I ask this because in rdflib apparently you can store the same triple twice (or more). This is the reader

import rdflib
from rdflib import store

s = rdflib.plugin.get('MySQL', store.Store)('rdfstore')

config_string = "host=localhost,password=foo,user=foo,db=foo"
rt = s.open(config_string,create=False)
if rt != store.VALID_STORE:
    s.open(config_string,create=True)

graph = rdflib.ConjunctiveGraph(s, identifier = rdflib.URIRef("urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52"))
rows = graph.query("SELECT ?id ?value { ?id <http://localhost#ha> ?value . }")
for r in rows:
    print r[0], r[1]

这是作家

import rdflib
from rdflib import store

s = rdflib.plugin.get('MySQL', store.Store)('rdfstore')

config_string = "host=localhost,password=foo,user=foo,db=foo"
rt = s.open(config_string,create=False)
if rt != store.VALID_STORE:
    s.open(config_string,create=True)

graph = rdflib.ConjunctiveGraph(s, identifier = rdflib.URIRef("urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52"))
graph.add( ( rdflib.URIRef("http://localhost/1000"), rdflib.URIRef("http://localhost#ha"), rdflib.Literal("18")) )
graph.commit()

这就是我所得到的

sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
table kb_7b066eca61_relations Doesn't exist
table kb_7b066eca61_relations Doesn't exist
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
sbo@dhcp-045:~/tmp/gd $ python ./writer2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
http://localhost/1000 18
sbo@dhcp-045:~/tmp/gd $ python ./writer2.py 
sbo@dhcp-045:~/tmp/gd $ python ./reader2.py 
http://localhost/1000 18
http://localhost/1000 18

对我来说,它似乎是一个错误.修改后的版本告诉我,两个三元组都属于同一个上下文,并且确实也有两个三元组

To me it appears as a bug. A modified version shows me that both triples belong to the same context, and there are indeed two triples as well

len : 2
http://localhost/1000 18
http://localhost/1000 18
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)
(rdflib.URIRef('http://localhost/1000'), rdflib.URIRef('http://localhost#ha'), rdflib.Literal(u'18'), <Graph identifier=urn:uuid:a19f9b78-cc43-4866-b9a1-4b009fe91f52 (<class 'rdflib.Graph.Graph'>)>)

推荐答案

RDF三元组存储是一组三元组,因此,根据定义,同一三元组不能出现两次.但是,大多数rdf存储实际上是四元组存储(rdf图集也称为数据集),在这种情况下,三元组可能会出现多次.根据商店的不同,有时也称为上下文(例如,我的 Redland ).权限实际上取决于用户定义特定图形名称/上下文名称的含义.

An RDF triple store is a set of triples, so the same triple cannot be present twice, by definition. However, most rdf stores are actually quad stores (sets of rdf graphs also known as datasets) and in that case, the triple may appear multiple times. That is sometimes called context, depending on the store (eg mine, Redland). Authority is really up to the user to define what meaning a particular graph name/context name has.

这篇关于RDF中的三元组重复,权威性观点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆