SDM-TIB / SDM-RDFizer

An Efficient RML-Compliant Engine for Knowledge Graph Construction
https://doi.org/10.5281/zenodo.3872103
Apache License 2.0
107 stars 25 forks source link

Mapping rules for creating complex triple relation #109

Closed Gautamshahi closed 7 months ago

Gautamshahi commented 7 months ago

Hello,

I would like to create a triple with a literal value; for example, Country A | hasMigrantFrom | Country B |
Country A | hasMigrants | 1 million |

Here, I am not able to relate that Country A hasMigrants of 1 million from Country B.

Can you please suggest an example or possible change in the mapping rules?

eiglesias34 commented 7 months ago

Hello,

Triples can only represent binary relationships. Therefore, to express n-nary (n being greater than 2) relationships or binary with attributes (like your example) in RML, you need a triples map that only represents the relationship. In your case, the subject should be something that uniquely identifies these immigration routes, like a combination of the countries. The attributes of the triples map should be the departure country, the destination country, and the number of immigrants.

I hope this helps, SIncerely, Enrique Iglesias

Gautamshahi commented 7 months ago

Thanks, Enrique, it helps a lot. Technically, I was near to this concept, but struggling in writing the mapping rules, can you share some examples or previously developed or current KG in your knowledge? It will be really appreciated.

dachafra commented 7 months ago

@Gautamshahi another option is to use any of the reification approaches that allow you to do statements about statements. You can check this paper for more info: https://davidchavesfraga.com/outcomes/papers/2023/iglesias2023reconstruction.pdf

eiglesias34 commented 7 months ago

Hello @Gautamshahi,

Here is an example:

<#Migration> a rr:TriplesMap;
  rml:logicalSource [
    rml:source "";
    rml:referenceFormulation ql:CSV;
  ];
  rr:subjectMap [
    rr:template "https://example.org/{CountryA}_{CountryB}";
    rr:class ex:Migration;
  ];
  rr:predicateObjectMap [
    rr:predicate ex:sourceCountry;
    rr:objectMap [
      rr:template "https://example.org/{CountryA}";
    ]
  ];
  rr:predicateObjectMap [
    rr:predicate ex:destinationCountry;
    rr:objectMap [
      rr:template "https://example.org/{CountryB}";
    ]
  ];
  rr:predicateObjectMap [
    rr:predicate ex:numberImmigrants;
    rr:objectMap [
      rml:reference "number_immigrants";
    ]
  ].

Please, next time, send your questions directly to me (since you already have my skype). The issue board for SDM-RDFizer is reporting issues with the tool.

Sincerely, Enrique