Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

request support for sparql #869

Closed
amorgat opened this issue Jan 25, 2018 · 7 comments
Closed

request support for sparql #869

amorgat opened this issue Jan 25, 2018 · 7 comments

Comments

@amorgat
Copy link

amorgat commented Jan 25, 2018

I'd like to use a sparql kernel (e.g https://github.com/paulovn/sparql-kernel) inside a SoS notebook and exchange data (SPARQL queries or SPARQL results) with the other kernels.
Do you think it could be manageable?

@BoPeng
Copy link
Contributor

BoPeng commented Jan 25, 2018

I can confirm that sparql works in SoS. If we need a language module for it, we will need some reference for types of variables used in sparql.

image

@BoPeng
Copy link
Contributor

BoPeng commented Jan 25, 2018

OK, my understanding from paulovn/sparql-kernel#20 is that there is no concept of variables in this kernel so magics such as %get does not make sense. As @paulovn pointed out, your best bet would be outputting the results to a file and process them in another language. Something like

image

@paulovn
Copy link

paulovn commented Jan 25, 2018

Hi. Given that the %expand magic essentially covers the task of inserting variables in the kernel (since input to SPARQL queries are basically strings), what may remain is fetching query results. Though the hack of saving to a file works, it might also be possible to load query results on demand into a variable so that they are made available to %get (it would be a single variable per cell, likely with always a pre-defined name)

SPARQL query result format depends on the MIME type requested to the endpoint, but for export purposes it could be a JSON (or, if format is N3, a table that could be exported as a dataframe-like structure).

I'll try to take a look at the documentation for getting variables out of the kernel and into SoS, to see how difficult would that be

@BoPeng
Copy link
Contributor

BoPeng commented Jan 25, 2018

Parsing output file from sparql in Python or R is almost good enough because most languages can parse JSON. A new capture magic can help a bit but you would have to transfer the variables to another kernel (e.g. R) if you need to process the data in other kernels. So in the end you are looking at something like

%capture --from output.txt --to var
%outfile output.txt
sparql stuff

---- (R)
%get var

R stuff

@amorgat
Copy link
Author

amorgat commented Jan 27, 2018

Thanks guys!
I have been able to convert my working notebook (sparql kernel) into a sos notebook and use %outfile to exchange data with another notebook. Waiting for you to transfer variables ;-)

@BoPeng
Copy link
Contributor

BoPeng commented Jan 27, 2018

Note that there is now a new %capture json —from file —to var magic to create a dictionary from file. It will be included in the next release of sos-notebook after more testing.

@amorgat
Copy link
Author

amorgat commented Jan 27, 2018

goody!!

@BoPeng BoPeng closed this as completed Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants