I need to find URIs of skos:Concept using skos:prefLabel (literal) from other skos:Concept. Here is my query:
SELECT ?variableURI ?variablePref ?entityPrefRegex ?entityURI ?entityPref WHERE {
?variableURI skos:prefLabel ?variablePref .
FILTER(REGEX(?variablePref,"^Dissolved .* in surface water"))
BIND(REPLACE(?variablePref,"^Dissolved (.*) concentration in surface water", "$1") AS ?entityPrefRegex).
?entityURI skos:prefLabel ?entityPref .
FILTER(REGEX(?entityPref,?entityPrefRegex,"i"))
}
My problem is that the filtering part return no result and I don't understand why.
Here are sample variables I'm trying to link my entities
variableURI | variablePref | entityPrefRegex |
---|---|---|
<:c_7e508e0e> | "Dissolved aluminium concentration in surface water"@en | "aluminium"@en |
<:c_b5dec35c> | "Dissolved arsenic concentration in surface water"@en | "arsenic"@en |
<:c_bc765ffd> | "Dissolved boron concentration in surface water"@en | "boron"@en |
<:c_4ce4d2c7> | "Dissolved caesium concentration in surface water"@en | "caesium"@en |
And the corresponding entities. As you can see the literal are identical except for the capital letter.
entityURI | entityPref |
---|---|
<:c_d57d0742> | "Aluminium"@en |
<:c_d57d077> | "Arsenic"@en |
<:c_d57d0728> | "Boron"@en |
<:c_d57d0745> | "Caesium"@en |
The pattern (second) argument to REGEX
is a "simple literal" (a literal "without language tag or datatype IRI"). In this case, it looks like you are using ?entityPref
values that have the @en
language tag:
FILTER(REGEX(?entityPrefRegex,?entityPref,"i"))
Try instead casting the pattern to a plain string:
FILTER(REGEX(?entityPrefRegex,STR(?entityPref),"i"))