LinkedMDB SPARQL 查询 [英] LinkedMDB SPARQL Query

查看:54
本文介绍了LinkedMDB SPARQL 查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有点困惑.我有以下 SPARQL 查询,它非常适合 LinkedMDB explorer.

I'm a bit confused here. I have the following SPARQL query that works brilliantly against the 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')
}

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

This one filters out all the Batman movies like this (I've filtered out all the results and is only showing five here):

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

但是,问题来了.如果我写阿甘正传"而不是蝙蝠侠",查询将找不到任何结果.

But, here comes the question. If I write "Forrest Gump" instead of "Batman", the query can't find any result.

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

However, if I change the last line to

    ?resource dc:title "Forrest Gump". 

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

it finds the movie in the LinkedMDB database, so I know its hiding there somewhere. But it's not returned when I use the FILTER regex solution.

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

I've noticed that if I only search without filter and just print all the movies in the database, it looks like LinkedMDB have some sort of LIMIT on 2557 so that the webpage won't crash. And it looks like the FILTER only filters those 2557 movies. Is there a way to retrieve more movies?

推荐答案

SPARQL 1.1 引入了更多字符串函数,例如 包含strstartsstrends 更专业化,速度更快而不是使用完整的正则表达式.但是,LinkedMDB 资源管理器似乎还不支持 SPARQL 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 结果

返回电影 db:电影/38179.

这篇关于LinkedMDB SPARQL 查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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