Open VladimirAlexiev opened 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.
Agree, this sounds better. Please also add some test cases. Cheers!
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?
prefixes:
ex: "http://example.com/"
mappings:
person:
sources:
- ['persons.json~jsonpath', '$.persons[*]']
s: http://example.com/person/$(firstname)
po:
- [a, foaf:Person]
- [ex:lastName, $(lastname), $(lang)~lang]
- [ex:score, $(num), $(dt)]
Data:
{
"persons": [
{
"firstname": "John",
"lastname": "Doe",
"lang": "en",
"num": 3,
"dt": "xsd:integer",
},
{
"firstname": "Jane",
"lastname": "Smith",
"lang": "fr",
"num": "3.14",
"dt": "xsd:decimal",
},
]
}
RML:
map:om_2 a rr:ObjectMap;
rml:reference "lastname";
rr:termType rr:Literal;
rr:language "$(lang)". ## close but not quite
map:om_3 a rr:ObjectMap;
rml:reference "num";
rr:termType rr:Literal;
rr:datatype <$(dt)>. ## See next issue
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 standardrr: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!