2

我在这里有点困惑。我有以下 SPARQL 查询,可以很好地与LinkedMDB explorer 配合使用

 PREFIX mdb: <http://data.linkedmdb.org/resource/movie/film>
 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX dc: <http://purl.org/dc/terms/>

 SELECT ?label?resource WHERE {
    ?resource mdb:id ?uri .
    ?resource dc:title ?label . 
    FILTER regex(?label,'^Batman')
}

这个过滤掉了所有像这样的蝙蝠侠电影(我已经过滤掉了所有的结果,这里只显示了五个):

-----------------------------------------------|
| Label                           | Resource   |
|----------------------------------------------|
| Batman                          | db:film/2  |
| Batman                          | db:film/3  |
| Batman & Robin                  | db:film/4  |
| Batman: Mask of the Phantasm    | db:film/737|
| Batman: Mystery of the Batwoman | db:film/974|
-----------------------------------------------|

但是,问题来了。如果我写“阿甘正传”而不是“蝙蝠侠”,则查询找不到任何结果。

但是,如果我将最后一行更改为

    ?resource dc:title "Forrest Gump". 

它在 LinkedMDB 数据库中找到了这部电影,所以我知道它藏在某个地方。但是当我使用该FILTER regex解决方案时它不会返回。

我注意到,如果我只搜索而不过滤并打印数据库中的所有电影,看起来 LinkedMDB 在 2557 上有某种限制,这样网页就不会崩溃。看起来 FILTER 只过滤了那些 2557 部电影。有没有办法检索更多电影?

4

1 回答 1

1

SPARQL 1.1 introduces more string functions, such as contains, strstarts, and strends which are much more specialized and could be much faster than using a full blown regular expression. However, it doesn't look like the LinkedMDB explorer supports SPARQL 1.1 yet, so those aren't useful here.

If you know the exact name of the movie, it will be much more efficient to simply ask for it instead of using regular expressions. E.g.,

SELECT ?resource WHERE {
    ?resource movie:filmid ?uri .
    ?resource dc:title "Forrest Gump" .
}

SPARQL Results

returns the film db:film/38179.

于 2013-09-13T13:26:16.440 回答