SPARQL - 进行反模式查询,select 遵守驼峰式命名法(无大写)的类名

SPARQL - Make a Anti pattern query that select the ClassName that respect the CamelCase (No uppercase)

我想查找 select ClassName 不以大写字母开头的查询。 架构是:

SELECT DISTINCT ?prop WHERE { { ?prop rdf:type owl:Class . } UNION { ?prop rdf:type owl:DatatypeProperty . } MINUS { #To DO }. }

您不能直接在您的 ?prop 上执行正则表达式,因为它可能包含您不想要的前缀。

首先你必须删除前缀(假设你的前缀是“:”)

bind(strafter(str(?class),str(:)) as ?propertyName)

它将创建一个名为 propertyName 的 var,它只包含名称(没有前缀)

既然你有了这个,你就可以对其执行正则表达式了。如果您只想保留以大写字母开头的属性,您可以这样做:

FILTER regex(str(?propertyName),"^[A-Z]")

注意:如果你想验证驼峰式的每条规则,你可以检查this regex