【问题标题】:semantic web request result difference语义网请求结果差异
【发布时间】:2014-12-10 15:34:09
【问题描述】:
PREFIX dbo: <http://dbpedia.org/ontology/>

    SELECT * WHERE {
     ?x foaf:primaryTopic ?n .
     ?x rdf:type ?z .

    FILTER (regex(?x, '^http://en.wikipedia.org/wiki/Barack_Obama$')).
}
LIMIT 10    

当我从http://dbpedia.org/snorql 调用此请求时,它可以工作。但是当我在下面尝试时

SELECT * WHERE {
 ?x foaf:primaryTopic ?n .
 ?x rdf:type ?z .
 ?x owl:activeYearsStartDate ?v .
 FILTER (regex(?x, '^http://en.wikipedia.org/wiki/Barack_Obama$')).
}    

它不起作用。但为什么?

【问题讨论】:

  • “它不起作用”是什么意思?您收到错误消息?你没有得到你期望的结果?什么?我打赌你不会得到任何结果,因为 OWL 没有定义属性 owl:activeYearsStartDate

标签: sparql semantics dbpedia


【解决方案1】:

我猜你的意思是

?x dbpedia-owl:activeYearsStartDate ?v.

而不是

?x owl:activeYearsStartDate ?v.

另外,在这里使用正则表达式比它需要的更昂贵。您可以检查 URI 的字符串值是否特别是

过滤器(str(?x) = "…")

但即使这样也比您需要的要多得多。如果您希望 ?x 成为 ,只需使用它而不是 ?x,或者使用值将 ?x 绑定到它:

SELECT * WHERE {
 <http://en.wikipedia.org/wiki/Barack_Obama> foaf:primaryTopic ?n .
 <http://en.wikipedia.org/wiki/Barack_Obama> rdf:type ?z .
 <http://en.wikipedia.org/wiki/Barack_Obama> owl:activeYearsStartDate ?v .
}    

SELECT * WHERE {
 values ?x { <http://en.wikipedia.org/wiki/Barack_Obama> }
 ?x foaf:primaryTopic ?n .
 ?x rdf:type ?z .
 ?x owl:activeYearsStartDate ?v .
}    

不过,仍然看起来很可疑。你确定你不想要 吗?使用 foaf:primaryTopic 东西真的让我觉得你想要的东西更像:

select * {
  ?x foaf:isPrimaryTopicOf <http://en.wikipedia.org/wiki/Barack_Obama> ;
     a ?type ;
     dbpedia-owl:activeYearsStartDate ?v
}
limit 10

SPARQL results

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-10
    • 1970-01-01
    相关资源
    最近更新 更多