Sparnatural icon indicating copy to clipboard operation
Sparnatural copied to clipboard

Add a parameter to use `lang(...) = "xx"` instead of langmatches(...,"xx") in the generated SPARQL query

Open lubianat opened this issue 3 years ago • 5 comments

Hello again!

I am having an issue while working with multilanguage on Wikidata. As Wikidata has multiple types of english ("en-gb", "en-ca" and so on) In this example, multiple "dientamoebiasis" are shown as there are "en", "en-gb" and "en-ca" labels on Wikidata.

image

This is a behaviour of FILTER(LANGMATCHES(LANG(?disease_label), "en")), but is this a desired behaviour?

Is there anyway to change/customize the code for generating FILTER(LANG(?disease_label) = "en") instead?

This would restrict the queries to exactly the target language, and avoid duplicates.

Thanks! Best, Tiago

lubianat avatar Jul 07 '22 19:07 lubianat

This is a behaviour of FILTER(LANGMATCHES(LANG(?disease_label), "en")), but is this a desired behaviour?

Yes

Is there anyway to change/customize the code for generating FILTER(LANG(?disease_label) = "en") instead?

Yes, by providing a custom SPARQL datasource : https://docs.sparnatural.eu/OWL-based-configuration-datasources#your-own-sparql-query-lists--autocomplete and see an example at https://github.com/sparna-git/sparnatural.eu/blob/main/demos/demo-smt-cim10/sparnatural-config.ttl#L117

tfrancart avatar Jul 08 '22 06:07 tfrancart

@tfrancart oh, thanks! I am missing something, perhaps, though. I am not referring to the labels returned by the drop down menus, but by the query itself.

This is handled by the code at https://github.com/sparna-git/Sparnatural/blob/b6a44595d2711197b7559b7fa4f09c281a8e1a8d/src/Query.js#L790-L809

and

https://github.com/sparna-git/Sparnatural/blob/b6a44595d2711197b7559b7fa4f09c281a8e1a8d/src/Query.js#L510-L517

Can I change this behaviour with datasource too?

lubianat avatar Jul 14 '22 16:07 lubianat

Ho yes sorry I misunderstood. You are right and you pointed to the right place in the code :-) and, no, this cannot be changed through datasources, unfortunately. We could add a config parameter to handle that, but would be an evolution

tfrancart avatar Jul 19 '22 08:07 tfrancart

Oh, I see. It would be great to have a config parameter for that! One more thing for the wishlist :) . Thanks again!

lubianat avatar Jul 20 '22 20:07 lubianat

Let's leave this issue opened as a wishlist entry. Keep on adding to the wishlist and ask questions :-)

tfrancart avatar Jul 21 '22 06:07 tfrancart