Giter Site home page Giter Site logo

example2rml's Introduction

example2RML

This JavaScript library generates a RML mapping based on data sources and corresponding RDF triples. It is available as a Node.js module.

Example

Consider the following table which we want to map to RDF.

id firstname lastname
0 john doe
1 james doe
2 Winston Peterson

Let's have a look at the first row. The corresponding RDF triples we would want, look like this:

<http://www.example.com/0> a foaf:Person;
  foaf:firstName 'john';
  foaf:familyName 'Doe'.

Using this library, an RML mapping can be generated by providing both the data source and the example RDF triples. The RML mapping will look something like this.

<#Mapping>
  rr:subjectMap [
    rr:class foaf:Person
  ];
  
  rr:predicateObjectMap [
    rr:predicate foaf:firstName;
    rr:objectMap [
      rml:reference 'firstname'
    ]
  ];
  
  rr:predicateObjectMap [
    rr:predicate foaf:familyName;
    rr:objectMap [
      rml:reference 'lastname'
    ]
  ].

Usage

Node.js

Install the module via npm install example2rml. Below you can find an example on how to use the module.

let example2rml = require('example2rml');

let triples = [{
  subject: 'http://www.example.com/pieter',
  predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
  object: 'http://www.example.com#Person'
}, {
  subject: 'http://www.example.com/pieter',
  predicate: 'http://www.example.com#firstName',
  object: '"Pieter"'
}, {
  subject: 'http://www.example.com/pieter',
  predicate: 'http://www.example.com#lastName',
  object: '"Heyvaert"'
}, {
  subject: 'http://www.example.com/pieter',
  predicate: 'http://www.example.com#age',
  object: '"26"'
}];

let dataSources = [{
  type: 'csv',
  row: [{
    column: 'firstname',
    value: 'Pieter'
  },{
    column: 'lastname',
    value: 'Heyvaert'
  },{
    column: 'age',
    value: '26'
  }]
}];

example2rml(triples, dataSources).then(console.log);

Command Line Interface

Install the module via npm install -g example2rml. You execute an example via example2rml -i ./demo/1/data.csv -t ./demo/1/example2rml.nt, where -i is a comma separated list of paths to input data sources and -t is the path to the example triples. More information and other options can be found via example2rml -h.

Supported Data Formats

At the moment CSV and JSON are supported.

Copyright

The example2rml library is written by Pieter Heyvaert.

This code is copyrighted by Ghent University – imec.

example2rml's People

Contributors

pheyvaer avatar

Stargazers

 avatar Brecht Van de Vyvere avatar Ismael Rodríguez avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.