class SymbolicData
Access to the database of ideals as provided by the SymbolicData Project (symbolicdata.org).
Attributes
The variables from the sd.ini file
The variables from the sd.ini file
The variables from the sd.ini file
The variables from the sd.ini file
The variables from the sd.ini file
Public Class Methods
The constructor parses the sd.ini file and sets up some variables. An optional parameter can be passed to select the SPARQL endpoint that should be used. The keywords for different SPARQL endpoints are defined in the sd.ini file.
The default SPARQL endpoint is the one from symbolicdata.org
# File examples/sdjas.rb, line 106 def initialize(sparql = 'symbolicdata.org') @_sparql = sparql @_ideals = nil #@_parser = SaveConfigParser.new(['sd.ini','examples/sd.ini']) @_parser = ConfigParser.new('examples/sd.ini') if File.file?('examples/sd.ini') @_parser = ConfigParser.new('sd.ini') if File.file?('sd.ini') @sd = @_parser['symbolicdata']['sd'] begin @url = @_parser['sparql'][@_sparql] rescue raise ArgumentError, "The SPARQL endpoint referenced by '#{@_sparql}' was not found in the sd.ini file." end @sdhost = @_parser['DEFAULT']['sdhost'] sh, sp, port = @url.partition(':') # hack for subst and GI host error @url = @sdhost + sp + port @sqpath = @_parser['sparql']['path'] #puts "SymbolicData() initialized" #puts "url = " + str(@url) #puts "sdhost = " + str(@sdhost) end
Public Instance Methods
Returns an ideal as a Jas object that is ready to be used by Jas.
# File examples/sdjas.rb, line 155 def get_ideal(uri) return SD_Ideal.new(self, uri).get_ideal(); end
Returns a Python list of ideals.
# File examples/sdjas.rb, line 130 def get_ideals(force_reload = false) if @_ideals == nil or force_reload == true list_ideals(false, force_reload) end return @_ideals end
Returns an internal object that represents the SymbolicData database object. (See below for details)
# File examples/sdjas.rb, line 163 def get_sd_ideal(uri) return SD_Ideal.new(self, uri) end
Lists all the available ideals.
# File examples/sdjas.rb, line 140 def list_ideals(output = true, force_reload = false) if @_ideals == nil or force_reload == true r = SPARQL.new(self, @_parser['queries']['list_ideals']) ids = r.json['results']['bindings'] @_ideals = ids.map{ |x| _uri_to_name(x['ideal']['value']) } end if output _pprint(@_ideals) end end