Is there a buildin function to match statements by the language tag of literals in rdflib.js?
graph.match(me, speaks, $rdf.lit(undefined, 'en'))
didn’t work.
Would be quite useful…
Is there a buildin function to match statements by the language tag of literals in rdflib.js?
graph.match(me, speaks, $rdf.lit(undefined, 'en'))
didn’t work.
Would be quite useful…
That built-in doesn’t exist AFAIK. However it’s easy enough to do with map(). This will gather the subjects of all statements whose object is specified as English:
let all = store.match( null,null,null );
let en = all.map( (stm)=>{
if( stm.object.lang && stm.object.lang==="en" )
return stm.subject;
} );
Just a different style for nearly the same (filters out wrong languages instead of making them undefined
:
let en = store.match(null, null, null)
.filter(stm => stm.object.lang && stm.object.lang === "en");
Hi, I rather prefer modeling this in a different manner. The language can be modeled as an object on its own too, the annotation in literals is IMHO not the best fit. You’ll probably find an ontology having a language class and instances for the different languages. For example: https://schema.org/Language
Cheers.