Parent

SymbolicData

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

Attributes

_parser[R]
sd[R]
sdhost[R]
sqpath[R]
url[R]

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, line 105
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

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, line 154
def get_ideal(uri)
    return SD_Ideal.new(self, uri).get_ideal();
end
get_ideals(force_reload = false) click to toggle source

Returns a Python list of ideals.

# File examples/sdjas.rb, line 129
def get_ideals(force_reload = false)
    if @_ideals == nil or force_reload == true
        list_ideals(false, force_reload)
    end
    return @_ideals
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, line 162
def get_sd_ideal(uri)
    return SD_Ideal.new(self, uri)
end
list_ideals(output = true, force_reload = false) click to toggle source

Lists all the available ideals.

# File examples/sdjas.rb, line 139
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.