gpt4 book ai didi

limit - SPARQL 中的括号是什么?为什么链接的电影数据库限制为 2500 条记录?

转载 作者:行者123 更新时间:2023-12-05 08:28:06 27 4
gpt4 key购买 nike

以下 SPARQL 查询仅获取 2500 条有关 Actor 和电影的记录我不知道为什么限制为 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 ].
}
}

查询来自问题的答案:Querying the Linked Movie Database (LMDB) with SPARQL

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

我知道 a 关键字是 rdf:type 的替代品,我在没有参与者的情况下重写了一部分 SPARQL 查询。但是我还是搞不懂方括号[]的意思。

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.

}
}

感谢您的回复,但代码遗漏了一些电影 Actor 。例如电影“A Bridge Too Far”有 18 个 Actor ,但此查询的结果只有 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 个 Actor 而不是 18 个的相同结果

电影列表.rq

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 Query Language中有描述.特别是,参见 4.1.4 Syntax for Blank Nodes

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.

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.

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.

The following two forms

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

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

which is equivalent to the two triples:

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

and as an object:

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

which is equivalent to the two triples:

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

ardf:type

的简写

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

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

其实没什么好说的了。您可以使用 a 而不是 rdf: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" .

is syntactic sugar for:

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

LinkedMDB 施加了一些奇怪的限制

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

如果您需要获得一些超出默认返回范围的特定结果,您可能需要包含一个order by,然后是一个limit .即便如此,这个端点还是有一些奇怪的行为,对于特定问题,您最好直接与他们联系;其中一些异常并不表示您的查询有问题,而只是端点有问题。

关于limit - SPARQL 中的括号是什么?为什么链接的电影数据库限制为 2500 条记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22311732/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com