class PubliSci::Writers::Builder

Public Instance Methods

from_store(endpoint_url,connection,variable_in=nil, variable_out=nil, verbose=true, save=true) click to toggle source
# File lib/publisci/writers/dataframe.rb, line 65
def from_store(endpoint_url,connection,variable_in=nil, variable_out=nil, verbose=true, save=true)
  unless variable_in && variable_out
    puts "no variable specified. Simple inference coming soon" if verbose
    return
  end
  puts "connecting to endpoint at #{endpoint_url}" if verbose
  sparql = SPARQL::Client.new(endpoint_url)
  # client = PubliSci::Client.new
  query = PubliSci::QueryHelper.new

  rows = query.get_ary(sparql.query(query.row_names(variable_in))).flatten

end
from_turtle(turtle_file, connection, variable_in=nil, variable_out=nil, verbose=true, save=true) click to toggle source
# File lib/publisci/writers/dataframe.rb, line 45
def from_turtle(turtle_file, connection, variable_in=nil, variable_out=nil, verbose=true, save=true)
  unless variable_in && variable_out
    puts "no variable specified. Simple inference coming soon" if verbose
    return
  end
  puts "loading #{turtle_file}" if verbose
  repo = RDF::Repository.load(turtle_file)
  puts "loaded #{repo.size} statements into temporary repo" if verbose
  # connection = Rserve::Connection.new
  query = PubliSci::QueryHelper.new
  rows = get_rownames(variable_in, query, repo)
  puts "frame has #{rows.size} rows" if verbose

  vectors = get_vectors(variable_in, query, repo)
  puts "got vectors of size #{vectors.first.last.size}" if verbose && vectors.first

  create_dataframe(variable_out, connection, rows, vectors)
  save_workspace(connection, connection.eval('getwd()').to_ruby) if save
end