Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rml:languageMap #9

Open
VladimirAlexiev opened this issue Aug 2, 2019 · 4 comments
Open

add rml:languageMap #9

VladimirAlexiev opened this issue Aug 2, 2019 · 4 comments

Comments

@VladimirAlexiev
Copy link

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
Copy link

andimou commented Aug 2, 2019

@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
Copy link
Author

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

@gedro
Copy link

gedro commented Oct 27, 2019

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
Copy link
Author

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

@VladimirAlexiev VladimirAlexiev changed the title add rrx:languageColumn add rml:languageMap Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants