RMLio / RML-Mapper

Generate High Quality Linked Data from multiple originally (semi-)structured data (legacy)
http://RML.io
52 stars 20 forks source link

How could i generate namespace while generating TTL file #30

Closed vimaldarjiv26 closed 6 years ago

vimaldarjiv26 commented 6 years ago

I want to generate namespace in TTL file. while I am testing with RML Mapper it doesn't generate namespace only subject map, predicate object map and object map generated. for example, I need to add all namespace prefix to TTL file like below, @prefix rr: http://www.w3.org/ns/r2rml#. @prefix rml: http://semweb.mmlab.be/ns/rml# . @prefix ql: http://semweb.mmlab.be/ns/ql# . @prefix xsd: http://www.w3.org/2001/XMLSchema#. @prefix ex: http://www.example.com/ . @prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#. @prefix rdfs: http://www.w3.org/2000/01/rdf-schema#.

zacharywhitley commented 6 years ago

You could fairly easily, depending on the size of your data, in a post processing step. You can use either rapper or the Jena riot command. The usage with riot is somewhat non-obvious just by looking at the docs. You just need to include an empty ttl file with just the prefixes you want to the list of documents you'd like to process.

riot --output=ttl myprefixes.ttl mydata.ttl

pheyvaer commented 6 years ago

@vimaldarjiv26 Including prefixes is not a function of the mapper at this moment. Did the solution that @ZacharyWhitley provided work for you?

vimaldarjiv26 commented 6 years ago

Sorry for the late reply, No I am totally beginner please help me how to use this command

riot --output=ttl myprefixes.ttl mydata.ttl

Please tell me @ZacharyWhitley how to do it with java so that I can integrate it with my code.

zacharywhitley commented 6 years ago

The riot command can be used from the command line after you have run your mapping. If you'd like to do it in code that will obviously depend on what you're writing it in but I'm going to assume you're using Java and RDF4J. You need to call setNamespace on your Model. http://docs.rdf4j.org/javadoc/2.2/org/eclipse/rdf4j/model/Model.html

vimaldarjiv26 commented 6 years ago

I am using apache Jena so I have used below code to set namespaces model.setNsPrefix() Now it's working fine. Thanks for help @ZacharyWhitley