building of an RDF/SKOS graph

Hi,

I would like to build a RDF/SKOS graph.

I started like this:

*require 'rubygems'
require 'rdf'
require 'rdf/turtle'
require 'uuid'

include RDF

RDF::Turtle::Writer.open("my_skos_model.ttl") do |writer|
  writer << RDF::Graph.new do |graph|

    bnode     = RDF::Node.new # a blank node

    predicate_1 = RDF::type
    object_1    = RDF::SKOS.Concept


    predicate_2 = RDF::SKOS.prefLabel
    object_2    = RDF::Literal.new("some_label", :language => :en)

    graph << RDF::Statement.new(bnode, predicate_1, object_1)
    graph << RDF::Statement.new(bnode, predicate_2, object_2)

  end
end*

This give me as output :


 [ a <http://www.w3.org/2004/02/skos/core#Concept>;
    <http://www.w3.org/2004/02/skos/core#prefLabel> "some_label"@en] .

but I would like to have something like this:

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
@prefix skos: <http://www.w3.org/2004/02/skos/core#>.
@prefix dct: <http://purl.org/dc/terms/>.
@prefix : <http://mydomain/>.

:_00000001 a skos:Concept;
           skos:prefLabel "some_label"@en.

How can I have in the output
- the list of shema ?
- the bnode

Thanks in advance for your help

Antoine

Received on Saturday, 19 May 2012 05:34:43 UTC