English 中文(简体)
不能按照当地确定的前提提取三倍的卢旺达国防军
原标题:Cannot extract RDF triple by locally defined predicate

也许,我只能掌握一些基本思想,而这里却提出了我的问题。 我试图从卢旺达国防军的储存中提取三倍(使用4个仓库,但也尝试过XMLKnife)和SPARQL的盘问,明确了前线,取得了空洞的结果。

当然,我不像卢旺达国防军的辛塔克斯一号那样做任何事情,而是使用“和解”生成的数据(其范围被缩小到一个适合实例的规模)。

<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF
  xml:base = "http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl"
  xmlns:rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
  xmlns:owl="http://www.w3.org/2002/07/owl#"
  xmlns:ub="univ-bench.owl#"
>

<owl:DatatypeProperty rdf:ID="name">
  <rdfs:label>name</rdfs:label>
</owl:DatatypeProperty>

<owl:Class rdf:ID="Organization">
  <rdfs:label>organization</rdfs:label>
</owl:Class>

<owl:Class rdf:ID="University">
  <rdfs:label>university</rdfs:label>
  <rdfs:subClassOf rdf:resource="#Organization" />
</owl:Class>

<ub:University rdf:about="http://www.University0.edu">
   <ub:name>University0</ub:name>
</ub:University>

</rdf:RDF>

然后,我问,在进口后,我数据库实际包含的三倍:

SELECT * WHERE {?s ?p ?o} ORDERBY ?s

结果是:

<http://www.University0.edu>    <univ-bench.owl#name>   "University0"
<http://www.University0.edu>    <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <univ-bench.owl#University>
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#Organization>         <http://www.w3.org/2000/01/rdf-schema#label>    "organization"
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#Organization>     <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <http://www.w3.org/2002/07/owl#Class>
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#University>       <http://www.w3.org/2000/01/rdf-schema#subClassOf>       <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#Organization>
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#University>       <http://www.w3.org/2000/01/rdf-schema#label>    "university"
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#University>       <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <http://www.w3.org/2002/07/owl#Class>
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#name>     <http://www.w3.org/2000/01/rdf-schema#label>    "name"
<http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#name>     <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>       <http://www.w3.org/2002/07/owl#DatatypeProperty>

显而易见的是,我有<代码><univ-bench.owl#name>作为头三者的一部分。

Nevertheless following query returns no results:

SELECT * WHERE {?s <univ-bench.owl#name> ?o}

I ve tried dozens of combinations, with namespaces and without, but can t make it work. Can anyone explain why RDF engine doesn t find a predicate that s obviously there?

BTW, extracting the same triple with OBJECT="University0" works OK.

最佳回答

This is invalid:

<代码>xmlns:ub=“univ-bench.owl#”

姓名: URIsmust在RDF/XML中是绝对的。 (在Turtle等其他合成类动物中,可以比较,但在RDF/XML中则不是这样。) 如果你的例子确实是用“互换”直接产生的,那么“互换”就会被打破。 这一工作应当:

xmlns:ub=” http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#"

当然,你需要在SPARQL问询中,如@RobV。

问题回答

I suspect your problem is that you are not trying to match the correct URI in your query:

SELECT * WHERE {?s <univ-bench.owl#name> ?o}

Anything enclosed in angle brackets is treated as a URI and since you ve used a relative URI the SPARQL processor is presumeably resolving it against some arbitrary base resulting in an absolute URI different from the one in your data thus your query won t match anything.

What you need to do is either specify the full URI like so:

SELECT * WHERE {?s <http://www.lehigh.edu/~zhp2/2004/0401/univ-bench.owl#name> ?o}

Or use a prefix like so:

PREFIX ub: <univ-bench.owl#>
SELECT * WHERE { ?s ub:name ?o }

If none of these are working then I suspect it is some issue with relative URIs. My advice would be never use relative URIs, always use absolute URIs wherever possible. If you must use relative URIs always specify a Base URI explicitly i.e. ensure your data used absolute URIs, reload it into your store and try again.

可在以下网站查阅:xml:base=”http://example.org> in RDF/XML或BASE <http://example.org/> in SPARQL。 如果使用4个仓库,我认为其进口商的指挥线有可用来确定URI在未指明的情况下的违约基数的论点。

你可能要做的另一件事是试图把你的数据放在另一个三倍的仓库中,如果你这样做的话,你是否经历过同样的行为,就意味着像我所建议的那样,存在相对的绝对的“国际独立”问题。 如果其他仓库回答询问的罚款,则建议与4个仓库进行可能的浏览,在这种情况下,你应当在其邮寄名单上与他们联系——





相关问题
Defining cardinality for a RDF statement

Im having a problem with RDF. I have a couple of triples defined as : <User rdf:about="#T"> <hasName rdf:datatype="http://www.w3.org/2001/XMLSchema#string">T</hasName> <...

Duplicate triple in RDF, authoritative view?

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 ...

Pick and RDF/SPARQL

Anyone have any interest in intergrating RDF and/or SPARQL with a PICK database? Has anyone tried this yet? I have some thoughts about what to try. One idea is to figure out how to create a file with ...

Using contexts in rdflib

I am having trouble finding a clear, sensible example of usage of context with rdflib. ConjunctiveGraph does not accept contexts, and Graph is deprecated. How am I supposed to create and operate on ...

What is the difference between RDF and OWL? [closed]

I am trying to grasp the concept of Semantic Web. I am finding it hard to understand what exactly is the difference between RDF and OWL. Is OWL an extension of RDF or these two are totally different ...

Problem with SPARQLWrapper (Python)

I m making a SPARQL query against the Sesame store in localhost, using SPARQLWrapper: sparql = SPARQLWrapper( http://localhost:8080/openrdf-sesame/repositories/rep/statements ) sparql.setQuery(...

热门标签