[英]How to build case-insensitive SPARQL filter?
I am trying to build some queries with SPARQL searching by the label field without case sensivity. 我正在尝试使用SPARQL通过按标签字段进行搜索来构建一些查询,而不区分大小写。
I start from this query which works fine: 我从这个查询开始,它运作良好:
SELECT distinct ?concepto, ?objeto, ?label WHERE {?concepto rdfs:comment ?objeto. ?concepto rdfs:label ?label. FILTER (lang(?label) = 'es' && ?label='Francisco de Quevedo'@es && (lang(?objeto) = 'es' || lang(?objeto) = 'en'))} LIMIT 100
But if I try to add a FILTER constraint to make the query case insensitive, it doesn't work: 但是,如果我尝试添加FILTER约束以使查询不区分大小写,那么它将不起作用:
SELECT distinct ?concepto, ?objeto, ?label WHERE {?concepto rdfs:comment ?objeto. ?concepto rdfs:label ?label. FILTER (lang(?label) = 'es' && lcase(str(?label))='francisco de quevedo'@es && (lang(?objeto) = 'es' || lang(?objeto) = 'en'))} LIMIT 100
Diferent options to do queries searching by labels searching general concepts (ie: Galaxy, Mountain, Francisco de Quevedo). 通过标签搜索一般概念(例如:Galaxy,Mountain,Francisco de Quevedo)进行查询搜索的不同选项。 I need to identify only one object that contains this topics and I don't know previously if the label is registered in lower or upper case.
我只需要标识一个包含此主题的对象,并且以前不知道标签是用小写还是大写注册的。
Next code doesn't work (it's a heavy query, and take all the objects that CONTAIN tha word Galaxy: 下一个代码不起作用(这是一个繁重的查询,并获取包含单词Galaxy的所有对象:
SELECT distinct ?concepto ?objeto ?label WHERE {?concepto rdfs:comment ?objeto. ?concepto rdfs:label ?label FILTER (lang(?label) = 'es' && (lang(?objeto) = 'es' || lang(?objeto) = 'en') && regex(?label, "Galaxia","i"))} LIMIT 100
This other code works fine, I obtain the correct object but I need to know exactly how it is write (upper or lower case): 其他代码工作正常,我获得了正确的对象,但是我需要确切地知道它是如何写的(大写或小写):
SELECT distinct ?concepto ?objeto ?label WHERE { ?concepto rdfs:comment ?objeto. ?concepto rdfs:label ?label FILTER (lang(?label) = 'es' && (lang(?objeto) = 'es' || lang(?objeto) = 'en') && ?label = "Galaxia"@es)} LIMIT 1000
And the last one is ok with the performance but obtain lots of results, I need to obtain only the object Galaxy searching by label in Spanish: 最后一个在性能上还可以,但是获得了很多结果,我只需要获取西班牙语中按标签搜索的对象Galaxy:
SELECT distinct ?concepto ?objeto ?label WHERE {?concepto rdfs:comment ?objeto. ?concepto rdfs:label ?label. ?label bif:contains '"Galaxia"' FILTER (lang(?label) = 'es' && (lang(?objeto) = 'es' || lang(?objeto) = 'en'))} LIMIT 100
应用STR(?label)
导致语言标签被删除,因此@es
从要比较的字符串中删除@es
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.