首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在基本sparql查询中应用基于regex的筛选器不返回结果。

在基本sparql查询中应用基于regex的筛选器不返回结果。
EN

Stack Overflow用户
提问于 2017-11-21 22:22:40
回答 1查看 155关注 0票数 0

以下查询:

代码语言:javascript
复制
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE 
{
  ?x qb:component ?subject .
}

通过这个可公开使用的端点进行部署:http://statistics.gov.scot/sparql-beta生成一个可用主题列表:

代码语言:javascript
复制
http://statistics.gov.scot/def/component-specification/pupil-attainment/refArea
http://statistics.gov.scot/def/component-specification/pupil-attainment/refPeriod
http://statistics.gov.scot/def/component-specification/pupil-attainment/measureType
http://statistics.gov.scot/def/component-specification/pupil-attainment/count
http://statistics.gov.scot/def/component-specification/pupil-attainment/pupils
http://statistics.gov.scot/def/component-specification/pupil-attainment/ratio

问题

我想使用regex过滤可用的结果,类似于链接示例

代码语言:javascript
复制
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>

SELECT ?g
WHERE
{ ?y vcard:Given ?g .
  FILTER regex(?g, "r", "i") }

当尝试时:

代码语言:javascript
复制
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE 
{
  ?a qb:component ?subject .
  FILTER regex(?subject, "p", "i")
}

查询返回没有行的表。有什么方法可以过滤得到的值吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-21 22:37:32

我认为您应该在str上调用?subject函数,它不是一个字符串,而是一个URI,所以首先必须将它转换为一个字符串。

这应该是可行的:

代码语言:javascript
复制
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE 
{
  ?a qb:component ?subject .
  FILTER regex(str(?subject), "p", "i")
}
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47423761

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档