【问题标题】:How to check whether something is a movie title, using a SPARQL query?如何使用 SPARQL 查询检查某事是否是电影标题?
【发布时间】:2017-04-24 07:39:52
【问题描述】:

我想在 SPARQL 中编写一个查询,如果我们提供任何输入名称,查询结果将判断它是否是电影片名。例如——

select distinct ?type where {
<http://dbpedia.org/resource/Inception> a ?type .
FILTER regex(str(?type), "^.*movie", "i") }

查询结果告诉我们这是一部电影。现在,当我们输入那些有歧义的名称时,它不会返回任何内容。

例如,如果我们输入Captain_Phillips 代替Inception,它会返回——什么都没有。

所以,我想知道如何在不明确的情况下获取名称是否是电影标题。

【问题讨论】:

  • 你有一个不起作用的例子吗?或者现在有什么问题?而且为什么不能问资源是属于dbo:Film还是schema:Movie这个类?

标签: sparql owl dbpedia


【解决方案1】:

http://dbpedia.org/resource/Captain_Phillips 是关于人的,而不是关于电影的。 http://dbpedia.org/resource/Captain_Phillips_(film) 是 scehma:Movie 类型。

试试:

SELECT DISTINCT 
?type 
WHERE 
{
<http://dbpedia.org/resource/Captain_Phillips_(film)> a ?type.

FILTER (regex(str(?type), "^.*movie", "i")). 
}

如果您只想检查结果是否存在:

ASK
{
<http://dbpedia.org/resource/Captain_Phillips_(film)> a ?type.

FILTER (regex(str(?type), "^.*movie", "i")). 
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-11
    • 2018-02-17
    • 1970-01-01
    • 2012-12-09
    • 2013-09-23
    • 1970-01-01
    相关资源
    最近更新 更多