kg-construct / rml-test-cases

RML conformance test suite
http://rml.io/test-cases/
Creative Commons Attribution 4.0 International
4 stars 11 forks source link

add rml:languageMap #9

Open VladimirAlexiev opened 5 years ago

VladimirAlexiev commented 5 years ago

This issue is about http://rml.io/spec.html but I couldn't find a repo for that spec. If this is the wrong repo for this issue, please let me know and I'll move it.

There is no standard way to take the lang tag of a literal from a data field. Back in Sep 2013 I proposed an extension rrx:languageColumn that does this (and uses the standard rr:language as fallback in case of missing value).

Please add this feature to RML. It uses a namespace rrx: http://purl.org/r2rml-ext/ but if you want, we can re-host it under the RML namespace to increase standardization/uptake.

Thanks!

andimou commented 5 years ago

@VladimirAlexiev thanks for the recommendation!

we encountered the same issue long time ago and we approached it by introducing the rml:languageMap property, following the same pattern as for subjectMap, predicateMap, objectMap. However we never documented it in the spec. Note to myself: update the spec.

The rml:languageMap expects an rr:TermMap in its range so all options, namely rr:template, rr:constant, rr:column, rml:reference are available. This way, rr:language acts as a short version of rml:languageMap when the rml:languageMap is combined with rr:constant, in the same way that rr:predicate acts as the shortcut of rr:predicateMap if the latter is combined with rr:constant.

See this test case https://github.com/RMLio/RML-Processor/tree/05266b836857f3c528db7a134fa0b84559a34432/src/test/resources/exampleLanguageMap

As a Term Map is combined with FnO.io for transformations, it is also possible to modify the value from the original data, e.g. if the original data value is "engish", a function can be used to change it to a valid language tag, e.g. "en".

As far as I see, rrx:languageColumn covers only references and it will also be difficult to have any modifications.

VladimirAlexiev commented 5 years ago

Agree, this sounds better. Please also add some test cases. Cheers!

gedro commented 5 years ago

Hi @andimou,

I've tried to use the test cases you mentioned above. In my opinion they shouldn't work because of rml:reference "Localization[@Culture]" part. This is a valid xPath for elements but the language value is in the Culture attribute. I also tried to replace it with: rml:reference "Localization/@Culture" but then I got the same language for all the literals. (I think this could be due to a bug) Could you please help me how to use properly the rml:languageMap with xPath rml:referenceFormulation?

VladimirAlexiev commented 4 years ago