RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
41 stars 17 forks source link

yarrrml-generator: doesn't support CSVW description #122

Open bjdmeest opened 3 years ago

bjdmeest commented 3 years ago

Following RML

@prefix rr: <http://www.w3.org/ns/r2rml#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rml: <http://semweb.mmlab.be/ns/rml#> .
@prefix ql: <http://semweb.mmlab.be/ns/ql#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix csvw: <http://www.w3.org/ns/csvw#> .

@prefix fnml:     <http://semweb.mmlab.be/ns/fnml#> .
@prefix fno:      <https://w3id.org/function/ontology#> .

@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix org: <http://www.w3.org/2004/02/skos/core#> .
@prefix rov: <http://www.w3.org/ns/regorg#> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix locn: <http://www.w3.org/ns/locn#> .

@base <http://knows.com/base/> .

<CustomerSource> 
    rml:source [
      a csvw:Table;
      csvw:url "../../data/general-customer-cleaned.csv";
      csvw:dialect [ 
        a csvw:Dialect;
        csvw:delimiter ";"
      ]
    ];
    rml:referenceFormulation ql:CSV
.

_:smOrganization
  a rr:SubjectMap;
  rr:template "{No_}";
  rr:class rov:RegisteredOrganization;
.

_:smSite
  a rr:SubjectMap;
  rr:template "site/{No_}"; # TODO: site identifier
  rr:class org:Site;
.

################################################################################
# TRIPLE MAPS

# Generates an Organization resource
<Organization>
  a rr:TriplesMap;

  rml:logicalSource <CustomerSource> ;

  rr:subjectMap _:smOrganization;

  rr:predicateObjectMap [ 
    rr:predicate org:identifier ;
    rr:objectMap [ rml:reference "No_" ];
  ] ;

   rr:predicateObjectMap [ 
    rr:predicate skos:prefLabel;
    rr:objectMap [ rml:reference "Name" ];
  ];

  rr:predicateObjectMap [ 
    rr:predicate skos:altLabel;
    rr:objectMap [ rml:reference "Search Name" ];
  ];

.

becomes following YARRRML

prefixes:
  rr: 'http://www.w3.org/ns/r2rml#'
  xsd: 'http://www.w3.org/2001/XMLSchema#'
  rml: 'http://semweb.mmlab.be/ns/rml#'
  ql: 'http://semweb.mmlab.be/ns/ql#'
  rdfs: 'http://www.w3.org/2000/01/rdf-schema#'
  csvw: 'http://www.w3.org/ns/csvw#'
  fnml: 'http://semweb.mmlab.be/ns/fnml#'
  fno: 'https://w3id.org/function/ontology#'
  foaf: 'http://xmlns.com/foaf/0.1/'
  org: 'http://www.w3.org/2004/02/skos/core#'
  rov: 'http://www.w3.org/ns/regorg#'
  skos: 'http://www.w3.org/2004/02/skos/core#'
  vcard: 'http://www.w3.org/2006/vcard/ns#'
  locn: 'http://www.w3.org/ns/locn#'
mappings:
  mapping0:
    sources:
      - [n3-0~csv]
    s: $(No_)
    po:
      - [a, 'http://www.w3.org/ns/regorg#RegisteredOrganization']
      - ['skos:identifier', $(No_)]
      - ['skos:prefLabel', $(Name)]
      - ['skos:altLabel', '$(Search Name)']

notice the n3-o :)