Skip to content

Instantly share code, notes, and snippets.

@arockwell
Created June 15, 2010 13:42
Show Gist options
  • Select an option

  • Save arockwell/439140 to your computer and use it in GitHub Desktop.

Select an option

Save arockwell/439140 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
require 'rubygems'
require 'rdf/raptor'
# Hash table of the name => uri of all data properties for a person
person_data_properties = {
"Gatorlink Username" => "http://vivo.ufl.edu/ontology/vivo-ufl/gatorlink",
"prefixName" => "http://purl.org/ontology/bibo/prefixName",
"firstName" => "http://xmlns.com/foaf/0.1/firstName",
"middleName" => "http://vivoweb.org/ontology/core#middleName",
"lastName" => "http://xmlns.com/foaf/0.1/lastName",
"suffixName" => "http://purl.org/ontology/bibo/suffixName",
"research keywords" => "http://vivoweb.org/ontology/core#freetextKeyword",
"orcidId" => "http://vivoweb.org/ontology/core#orcidId",
"overview" => "http://vivoweb.org/ontology/core#overview",
"preferredTitle" => "http://vivoweb.org/ontology/core#preferredTitle",
"researcherId" => "http://vivoweb.org/ontology/core#researcherId",
"scopusId" => "http://vivoweb.org/ontology/core#scopusId",
"UFID" => "http://vivo.ufl.edu/ontology/vivo-ufl/ufid",
"workEmail" => "http://vivoweb.org/ontology/core#workEmail",
"workPhone" => "http://vivoweb.org/ontology/core#workPhone",
"workFax" => "http://vivoweb.org/ontology/core#workFax",
"UF Active Directory Name" => "http://vivo.ufl.edu/ontology/vivo-ufl/activeDirName",
"UF Business Name" => "http://vivo.ufl.edu/ontology/vivo-ufl/businessName ",
"UF Department ID" => "http://vivo.ufl.edu/ontology/vivo-ufl/deptID"
}
# Retrieve Mike's rdf
mconlon_uri = "http://vivo.ufl.edu/individual/n25562/n25562.rdf"
mconlon_graph = RDF::Graph.load(mconlon_uri)
puts "Data properties for Mike Conlon"
# Table header
puts "+" + "-" * 26 + "+" + "-" * 105 + "+"
# For ever person data property, check if it is a predicate in Mike's rdf
person_data_properties.each do |k, v|
property_value = mconlon_graph.query(:predicate => RDF::URI.new(v))
# If the property isn't nil print a table row
if property_value[0] != nil
puts "| %-24s | %-103s |" % [k, property_value[0].object.value]
end
end
# Table footer
puts "+" + "-" * 26 + "+" + "-" * 105 + "+"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment