Re: Experimental Ruby SKOS API

Hi Dan!

You wrote:

> I started to make a Ruby API for SKOS.

Great. I am working on a Perl API for SKOS, Simon does one in Java -
good division of labour :-)

> I've posted some example snippet in See 
> http://svn.foaf-project.org/foaftown/2009/skosdex/readme.txt 
> which uses the UKAT SKOS dataset.

> s1 = SKOS.new()
> s1.read("file:samples/archives.rdf")
> c1 = s1.concepts["http://www.ukat.org.uk/thesaurus/concept/1366"]
> puts "test concept is "+ c1 + " " + c1.prefLabel
> c1.narrower do |uri|
>   c2 = s1.concepts[uri]
>   puts "\tnarrower: "+ c2 + " " + c2.prefLabel
>    c2.narrower do |uri|
>      c3 = s1.concepts[uri]
>      puts "\t\tnarrower: "+ c3 + " " + c3.prefLabel

I am currently thinking about a general design issue: where do you put
the relations? You could also do it this way:

s1 = SKOS.new("file:...");
c1 = s1.concepts[ "...uri..." ]
s1.narrower(c1) do |c2|
  puts "\tnarrower: "+ c2 + " " + c2.prefLabel
  s1.narrower(c2) do |c3|
    puts "\tnarrower: "+ c3 + " " + c3.prefLabel

This is first less code and second works also with concept schemes
without known URIs dynamically created concepts that don't have an URI
you want to propagate. On the other hand it may be less intuitive. The
most intuitive way would be:

s1 = SKOS.new("file:...");
c1 = s1.concepts[ "...uri..." ]
c1.narrower do |c2|
  puts "\tnarrower: "+ c2 + " " + c2.prefLabel
  c2.narrower do |c3|
    puts "\tnarrower: "+ c3 + " " + c3.prefLabel

But I am not sure how this can be managed without possibility to damage
consitency when editing the graph. For instance if you want to add a new
narrower relation between concept X and Y in a concept schema you may
have to change internal values of all these three objects. Maybe my
solution in Perl will be slightly different then a solution in Ruby or
Java because Perl does not have type checking and private attributes of
objects.

Greetings
Jakob

P..S.: Are you aware of the fact that in

> puts "test concept is "+ c1 + " " + c1.prefLabel

c.prefLabel may return an array if you have a multilingual concept
scheme?





-- 
Verbundzentrale des GBV (VZG)
Digitale Bibliothek - Jakob Voß
Platz der Goettinger Sieben 1
37073 Goettingen - Germany
+49 (0)551 39-10242
http://www.gbv.de
jakob.voss@gbv.de

Received on Saturday, 21 February 2009 18:50:44 UTC