class Rdf2Owl

Attributes

model[RW]

Public Class Methods

new(model) click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 8
def initialize(model)
  @model = model
  
end

Public Instance Methods

convert() click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 62
def convert()
   self.convert_RDFResource()
   self.convert_properties()
  self.convert_classes()
end
convert_RDFResource() click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 50
def convert_RDFResource()
  todelete = []
  @model.find(nil,nil,RDFS_RESOURCE){|s,p,o|
    @model.add(s,p,OWL_THING)
    todelete << Statement.new(s,p,o)
    log("Replaced triple #{s}:#{p}:#{o} with (x,x owl:Thing)")
  }
  todelete.each{|st| @model.delete_statement(st)}
  
  
end
convert_classes() click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 13
  def convert_classes()
    todelete = []
    @model.find(nil,TYPE,RDFS_CLASS) {|s,p,o|
      #log("found class #{s}:#{p}:#{o}")
      @model.add(s,p,OWL_CLASS)
      todelete << Statement.new(s,p,o)
log("Converted rdfs:Class #{s} into owl:Class")
    }
    todelete.each{|st| @model.delete_statement(st)}
    
    
  end
convert_properties() click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 26
  def convert_properties()
    todelete = []
    @model.find(nil,TYPE,PROPERTY) {|s,p,o|
      type = property_type(s)
      log("type is #{type}")
      @model.add(s,TYPE,type)
      todelete << Statement.new(s,p,o)
log("Converted rdf:Property #{s} into #{type}")
    }
    todelete.each{|st| @model.delete_statement(st)}
    
    
  end
log(message) click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 68
def log(message)
  puts "[RDF2OWL]" + message
end
property_type(prop) click to toggle source
# File lib/rdf/redland/convert_owl.rb, line 40
def property_type(prop)
  owl_object = false
  @model.find(prop,RDFS_RANGE,nil){|s,p,o|
    if o.resource?
      return OWL_OBJECT_PROPERTY
    end
  }
  return OWL_DATATYPE_PROPERTY
end