gpt4 book ai didi

regex - 处理 SPARQL-Filter 表达式中的特殊字符

转载 作者:行者123 更新时间:2023-12-02 10:14:13 26 4
gpt4 key购买 nike

我访问 dbpedia[1] 的 SPARQL-Endpoint 以获取给定城市的 URI。我使用以下查询来实现此目的:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
select distinct * where
{?uri rdfs:label ?label.
FILTER (REGEX(STR(?label), "^Köln$", "i")).
?uri a dbpedia:PopulatedPlace.
}

如果我查询一个没有德语变音符号的城市,一切正常,但如果有变音符号,我什么也得不到。当通过代码执行此查询时,我什至收到 406 错误( Not Acceptable )

知道如何处理针对 dbpedia 的 SPARQL 查询中的变音符号吗?

提前致谢,
弗兰克

[1] http://dbpedia.org/sparql

最佳答案

在处理你的角色时似乎存在错误,可能是在运输或其他方面。当你把它写在 unicode hex for ö 中时,它确实有效。 ,像这样:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/ontology/>
select distinct * where
{?uri rdfs:label ?label.
FILTER (REGEX(STR(?label), "^K\u00F6ln$")).
?uri a dbpedia:PopulatedPlace.
}

编辑:我现在发现这不适用于“i”标志。文档表明“u”标志适用于此。

关于regex - 处理 SPARQL-Filter 表达式中的特殊字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25449307/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com