Next episode: click here
Hello, and welcome to another episode of the RDFox introductory series.
In this episode, we're going to be covering how to use RDFox in the terminal. Specifically, we're going to cover how to create a data store, how to import some data, and how to run some queries for some results.
If you'd rather do any of these things in the web UI, check out our previous video where we covered the RDFox console in much more detail. Likewise, if you'd like some additional detail on the data, the context, or SPARQL queries in general, we have previous videos that again, go into those in much, much more detail than what we'll cover today.
So the first thing we need for this episode is a running version of RDFox in a terminal, and see here that I have a version of RDFox 7.4 running already.
From there, we're ready to create our first data store. We do this with command ‘dstore create’. Now I'm going to call my data store ‘f1’ in line with our workshop material, but if you're not following along with the workshop material, you're free to call this whatever you'd like.
So let's type our command ‘dstore create’ and give the data store name, in this case ‘f1’, and RDFox will tell us that a new data store ‘f1’ was created and initialised.
The next thing we need to do is to tell RDFox that all of the commands that we're about to run apply to this data store. It's very, very common in practice to have multiple data stores in one instance of RDFox when you have different projects on the go, so we need to say this data or these queries have to specifically apply to the data store that I want to avoid any kind of confusion.
So for this, I need the command active. I'm going to run ‘active f1’, and RDFox will tell me that the data store connection 'f1' is now active, so from here on out, every command we run will apply to this data store.
So from there, we're ready to import some data. You can see that we have two data files, two total files in our data folder, and in fact, the one that we're interested in today is upTo2020.ttl, so to import this file, we're going to use the ‘import’ command.
There's one additional detail that we need to be aware of though, and that is with prefixes. Some data files also contain prefixes, as this one does here, and sometimes we want to bring those prefixes in alongside our data. Other times we don't because we'll have those prefixes already defined in RDFox, but in this case we do, so we have to add the ‘+p’ flag to our command. So to import our upTo2020.ttl file with prefixes, we're going to use the command import +p and then the relative file path, which here is going to be data upTo2020.ttl, and by hitting enter, we can see that RDFox will import the four and a half million facts in a little over a second.
Now let's verify that we actually have this data in our data store by running a query. If we choose query 3 from our queries folder, we'll just be running a simple query that again, we've covered in a previous episode. If you're not sure what any of this means, go check that out first. To run any query against a data store, we're going to use the command ‘evaluate’ and again, use the relative file path.
So here we can use ‘evaluate queries/q3.rq’ and we will see that we get a total of 13 results from this query.
Now, sometimes we're going to want to actually see those results, so in order to do this, we have to run one more command, which is ‘set output out’.
This will mean that any result that you see will actually be printed to your terminal rather than just being hidden in the background. So let's set our output to out and rerun that query 3 again, once again using the evaluate command and this time we'll see that we have each of those 13 results printed out in our terminal.
The team behind Oxford Semantic Technologies started working on RDFox in 2011 at the Computer Science Department of the University of Oxford with the conviction that flexible and high-performance reasoning was a possibility for data-intensive applications without jeopardising the correctness of the results. RDFox is the first market-ready knowledge graph designed from the ground up with reasoning in mind. Oxford Semantic Technologies is a spin-out of the University of Oxford and is backed by leading investors including Samsung Venture Investment Corporation (SVIC), Oxford Sciences Enterprises (OSE) and Oxford University Innovation (OUI).