#!/usr/bin/env ruby # # script to read theyrule.net data from MySQL and # convert to RDF (FOAFCorp vocabulary). # # require "mysql" m = Mysql.new('localhost', 'foaf', 'foafcorp', 'foafcorp') header = < END makesql=nil onboard = {} puts (header) companies = m.query("select * from companies") companyfields = companies.fetch_fields.filter do |f| f.name end companies.each do |row| puts ("\n") puts (" \n \n ") puts (" \n") puts (" \n \n") corp = row[0] bods = row[2].split(',') bods.each do |bod| name = m.query("select distinct directors.firstname, directors.lastname from onboard, directors where directors.id = '#{bod}'") name.each do |namerecord| fullname = "#{namerecord[0]} #{namerecord[1]}\n".chomp!; personuri = "web:about=\"http://rdfweb.org/2002/02/theyrule#pid_#{bod}\" " puts (" \n") end end puts (" \n") puts (" \n") puts ("\n") end puts ("\n\n\n") ########################### SQL Schema info ############################ # # directors and companies are the tables that Josh exports # they both contain fields (boards, bod) that have arrays containing # links to the other table. We use these to generate a 3rd table, 'onboard' # making it convenient to do joins between these tables in SQL. # (aside: maybe MySQL lets us do this anyway? I don't know how) #directors: id firstname lastname gender boards url #companies: id companyname bod rank2001 url #onboard: corpid personid ########################### RDF Schema info ############################ # # The FOAFCorp RDF vocab we export to is an extension of RDFWeb's FOAF # vocabulary, containing classes and properties related to companies. # #http://rdfweb.org/people/danbri/2001/09/foafcorp/intro.html #http://rdfweb.org/people/danbri/2001/09/foafcorp/cola-corps-sample.xml # target example: # pepsi = < PEP ... END # Ruby MySQL code: # http://www.tmtm.org/en/mysql/ruby/README ## # random fragments # #directors = m.query("select * from directors") #directorfields = directors.fetch_fields.filter do |f| f.name end #puts directorfields.join("\t") #directors.each do |row| # puts row.join("\t") #end