在基本 sparql 查询中应用基于正则表达式的过滤器 returns 无结果
Applying regex-based filter in basic sparql query returns no results
以下查询:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?x qb:component ?subject .
}
通过此公开端点部署:http://statistics.gov.scot/sparql-beta 生成可用主题列表:
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
问题
我想使用正则表达式过滤可用结果,类似于 linked example:
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT ?g
WHERE
{ ?y vcard:Given ?g .
FILTER regex(?g, "r", "i") }
尝试时:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(?subject, "p", "i")
}
查询 returns table 没有行。有没有办法过滤获得的值?
我认为你应该在?subject
上调用str
函数,它不是一个字符串而是一个URI,所以首先你必须把它转换成一个字符串。
这应该有效:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(str(?subject), "p", "i")
}
以下查询:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?x qb:component ?subject .
}
通过此公开端点部署:http://statistics.gov.scot/sparql-beta 生成可用主题列表:
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
问题
我想使用正则表达式过滤可用结果,类似于 linked example:
PREFIX vcard: <http://www.w3.org/2001/vcard-rdf/3.0#>
SELECT ?g
WHERE
{ ?y vcard:Given ?g .
FILTER regex(?g, "r", "i") }
尝试时:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(?subject, "p", "i")
}
查询 returns table 没有行。有没有办法过滤获得的值?
我认为你应该在?subject
上调用str
函数,它不是一个字符串而是一个URI,所以首先你必须把它转换成一个字符串。
这应该有效:
PREFIX qb: <http://purl.org/linked-data/cube#>
SELECT DISTINCT ?subject
WHERE
{
?a qb:component ?subject .
FILTER regex(str(?subject), "p", "i")
}