class SymbolicData

Access to the database of ideals as provided by the SymbolicData Project (symbolicdata.org).

Attributes

_parser[R]

The variables from the sd.ini file

sd[R]

The variables from the sd.ini file

sdhost[R]

The variables from the sd.ini file

sqpath[R]

The variables from the sd.ini file

url[R]

The variables from the sd.ini file

Public Class Methods

new(sparql = 'symbolicdata.org') click to toggle source

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
106 def initialize(sparql = 'symbolicdata.org')
107     @_sparql = sparql
108     @_ideals = nil
109     #@_parser = SaveConfigParser.new(['sd.ini','examples/sd.ini'])
110     @_parser = ConfigParser.new('examples/sd.ini') if File.file?('examples/sd.ini')
111     @_parser = ConfigParser.new('sd.ini') if File.file?('sd.ini')
112     @sd = @_parser['symbolicdata']['sd']
113     begin
114         @url = @_parser['sparql'][@_sparql]
115     rescue
116         raise ArgumentError, "The SPARQL endpoint referenced by '#{@_sparql}' was not found in the sd.ini file." 
117     end
118     @sdhost = @_parser['DEFAULT']['sdhost']
119     sh, sp, port = @url.partition(':') # hack for subst and GI host error
120     @url = @sdhost + sp + port
121     @sqpath = @_parser['sparql']['path']
122     #puts "SymbolicData() initialized"
123     #puts "url    = " + str(@url)
124     #puts "sdhost = " + str(@sdhost)
125 end

Public Instance Methods

get_ideal(uri) click to toggle source

Returns an ideal as a Jas object that is ready to be used by Jas.

    # File examples/sdjas.rb
155 def get_ideal(uri)
156     return SD_Ideal.new(self, uri).get_ideal();
157 end
get_ideals(force_reload = false) click to toggle source

Returns a Python list of ideals.

    # File examples/sdjas.rb
130 def get_ideals(force_reload = false)
131     if @_ideals == nil or force_reload == true
132         list_ideals(false, force_reload)
133     end
134     return @_ideals
135 end
get_sd_ideal(uri) click to toggle source

Returns an internal object that represents the SymbolicData database object. (See below for details)

    # File examples/sdjas.rb
163 def get_sd_ideal(uri)
164     return SD_Ideal.new(self, uri)
165 end
list_ideals(output = true, force_reload = false) click to toggle source

Lists all the available ideals.

    # File examples/sdjas.rb
140 def list_ideals(output = true, force_reload = false)
141     if @_ideals == nil or force_reload == true
142         r = SPARQL.new(self, @_parser['queries']['list_ideals'])
143         ids = r.json['results']['bindings']
144         @_ideals = ids.map{ |x| _uri_to_name(x['ideal']['value']) }
145     end
146     if output
147         _pprint(@_ideals)
148     end
149 end