SPARQL中的括号是什么?为什么链接的电影数据库限制为2500条记录? [英] What are brackets in SPARQL and why is the linked movie database limited to 2500 records?

查看:84
本文介绍了SPARQL中的括号是什么?为什么链接的电影数据库限制为2500条记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下SPARQL查询仅获取与演员和电影的2500条记录,但我不知道为什么它限制为2500:

The following SPARQL query fetches only 2500 records with actors and films I don't know why its limited to 2500:

PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX movie: <http://data.linkedmdb.org/resource/movie/>

SELECT ?id ?filmTitle ?actorName WHERE { 
SERVICE <http://data.linkedmdb.org/sparql> {
?film a movie:film ;
      movie:filmid ?id ;
      dcterms:title ?filmTitle ;
      movie:actor [ a movie:actor ;
                    movie:actor_name ?actorName ].
  }
}

查询来自以下问题的答案:查询链接的对象具有SPARQL的电影数据库(LMDB)

The query is from an answer to the question: Querying the Linked Movie Database (LMDB) with SPARQL

a关键字是什么意思?方括号[]代表什么?

What does the a keyword mean? What do the square brackets [] stand for?

我知道a关键字是rdf:type的替代,并且我重写了SPARQL查询的一部分,但没有参与者.但是我仍然不知道方括号[]的含义.

I understood that the a keyword is a substitute for rdf:type and I rewrote a portion of the SPARQL query without the actors. But I still can't figure out the meaning of the square brackets [].

PREFIX movie: <http://data.linkedmdb.org/resource/movie/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT  ?film ?id ?filmTitle WHERE { 
#VALUES ?filmTitle { "The Matrix" }
SERVICE <http://data.linkedmdb.org/sparql> {
    ?film rdf:type movie:film.
    ?film movie:filmid ?id.
    ?film rdfs:label ?filmTitle.

  }
}

感谢您的回复,但是代码漏掉了一些电影演员.例如,电影"A Bridge Too Far"有18个演员,但此查询的结果只有2个

Thanks for your responses but the code misses out some actors for movies. For example the movie "A Bridge Too Far" has 18 actors but the result of this query has only 2

PREFIX dcterms: <purl.org/dc/terms/>; 
PREFIX movie: <data.linkedmdb.org/resource/movie/>; 
SELECT ?id ?filmTitle ?actorName 
WHERE { 
SERVICE <data.linkedmdb.org/sparql>;
 { 
  ?film a movie:film ; 
  movie:filmid ?id ;
  dcterms:title ?filmTitle ; 
  movie:actor [ a movie:actor ; 
           movie:actor_name ?actorName ]. 
 } 
} ORDER BY ASC(?filmTitle) 

我编辑的代码,仍然给出2个演员而不是18个的相同结果

My edited code, still giving same result of 2 actors instead of 18

PREFIX movie: <http://data.linkedmdb.org/resource/movie/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT  ?film ?id ?filmTitle ?actorName WHERE { 
  #VALUES ?filmTitle { "The Matrix" }
  SERVICE <http://data.linkedmdb.org/sparql> {
        ?film rdf:type movie:film.
        ?film movie:filmid ?id.
        ?film rdfs:label ?filmTitle.
        ?film movie:actor ?actorID.
        ?actorID movie:actor_name ?actorName.

  }
}
ORDER BY ASC(?filmTitle)

推荐答案

[…]是一个空白节点

SPARQL 1.1查询语言中描述了方括号.特别是,请参见 4.1.4空白节点的语法

[ … ] is a blank node

The square brackets are described in the SPARQL 1.1 Query Language. In particular, see 4.1.4 Syntax for Blank Nodes

4.1.4空白节点的语法

图形模式中的空白节点充当变量,而不是对 要查询的数据中的特定空白节点.

4.1.4 Syntax for Blank Nodes

Blank nodes in graph patterns act as variables, not as references to specific blank nodes in the data being queried.

空白节点由任一标签形式表示,例如"\_:abc", 或缩写形式"[]".仅在一个节点中使用的空白节点 查询语法中的位置可以用[]表示.独特的空白 节点将用于形成三重图案.空白节点标签为 对于带有标签"abc"的空白节点,写为"_:abc".一样的空白 节点标签不能在以下两个不同的基本图形模式中使用 相同的查询.

Blank nodes are indicated by either the label form, such as "\_:abc", or the abbreviated form "[]". A blank node that is used in only one place in the query syntax can be indicated with []. A unique blank node will be used to form the triple pattern. Blank node labels are written as "_:abc" for a blank node with label "abc". The same blank node label cannot be used in two different basic graph patterns in the same query.

[:p :v]构造可用于三重模式.它创建了一个 空白节点标签,用作所有包含的主题 谓词-宾语对.创建的空白节点也可以用于 在主体和客体的位置上还有其他三重模式.

The [:p :v] construct can be used in triple patterns. It creates a blank node label which is used as the subject of all contained predicate-object pairs. The created blank node can also be used in further triple patterns in the subject and object positions.

以下两种形式

[ :p "v" ] .
[] :p "v" .

分配唯一的空白节点标签(此处为"b57"),等效于 写作:

allocate a unique blank node label (here "b57") and are equivalent to writing:

_:b57 :p "v" .

此分配的空白节点标签可用作主题或对象 进一步的三重模式.例如,作为主题:

This allocated blank node label can be used as the subject or object of further triple patterns. For example, as a subject:

[ :p "v" ] :q "w" .

等同于两个三元组:

_:b57 :p "v" .
_:b57 :q "w" .

并作为对象:

:x :q [ :p "v" ] .

等同于两个三元组:

:x  :q _:b57 .
_:b57 :p "v" .

ardf:type

的简写

a is shorthand for rdf:type

关键字是什么意思?方括号[]代表什么 为?

What does the a keyword mean? What do the square brackets [] stand for?

我知道a关键字可以代替rdf:type

I understood that the a keyword is a substitute for rdf:type

没有什么比这更多的了.您可以使用a代替rdf:type:

There's not really much more to say than that. You can use a instead of rdf:type:

4.2.4 rdf:type

关键字"a"可以用作三元模式中的谓词,并且 IRI的替代品 http://www.w3.org/1999/02/22-rdf-syntax-ns#type.这个关键字是 区分大小写.

4.2.4 rdf:type

The keyword "a" can be used as a predicate in a triple pattern and is an alternative for the IRI http://www.w3.org/1999/02/22-rdf-syntax-ns#type. This keyword is case-sensitive.

?x  a  :Class1 .
[ a :appClass ] :p "v" .

是以下语言的语法糖:

?x    rdf:type  :Class1 .
_:b0  rdf:type  :appClass .
_:b0  :p        "v" .

LinkedMDB施加了一些奇怪的限制

LinkedMDB端点对查询结果施加了一些奇怪的限制.过去,其他一些问题和答案也涉及到这一点,

LinkedMDB imposes some odd limits

The LinkedMDB endpoint imposes some odd limits on query results. Some other questions and answers have touched on this in the past, including:

  • Can't retrieve movies with high IDs from LinkedMDB with SPARQL
  • LinkedMDB SPARQL Query

如果需要获取某些超出返回值默认范围的特定结果,则可能需要先包含order by,然后再包含limit.即使这样,此端点也有一些奇怪的行为,对于特定的问题,您最好还是直接与他们联系;其中一些奇怪之处并不表示您的查询有问题,而只是端点方面的问题.

If you need to get some specific results that are outside of the default range of what's returned, you'll probably want to include an order by and then a limit. Even so, this endpoint has some odd behavior, and for specific problems, you're probably best off contacting them directly; some of these oddities don't indicate a problem with your query, but are just a problem with the endpoint.

这篇关于SPARQL中的括号是什么?为什么链接的电影数据库限制为2500条记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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