Wiki
Clone wikisdaas / getting_started
Getting Started
SDaaS supports two distinct approaches:
- SDaaS Platform provides a programmatic approach to the building of the knowledge base. The SDaaS Platform consists of a command-line interface (CLI), built on the top of the well-known bash, that provides an additional command to drive data ingestion and reasoning. Using the SDaaS Platform, you can write and execute a script that builds the knowledge base from scratch.
- SDaaS Agent provides a declarative approach to the building of the knowledge base based on the KEES specifications. In a nutshell, you describe the knowledge base using RDF and let an agent find the most efficient way to ingest data and reasoning
Use the first approach if you need full control of the execution workflow, use the second approach if you plan to share your knowledge base in a self-contained, compact file set.
The SDaaS community edition supports only the platform approach; the SDaaS Enterprise Edition supports both the criteria with additional commands and features. In SDaaS EE, you can also mix both approaches for maximum flexibility.
The next chapters assume you already installed the SDaaS Platform
Getting started with the SDaaS Platform
When you launch the sdaas
command, it connects to the RDF store engine you decided using -k
command-line option, then it creates some debug and log files, and finally, it prompts for a command.
You can see installed SDaaS modules, available commands, and variables typing:
SD_STATUS
Note that all SDaaS commands are capitalized to distinguish to standard bash commands that are as well available.
You can execute a SPARQL Update script using the command SD_SPARQL_UPDATE.
For instance the command:
SD_SPARQL_UPDATE 'DROP ALL'
erases all data in the connected data store (be careful). You can get the same effect providing the option --reboot
at SDaaS CLI startup.
You can also pass a file to SD_SPARQL_UPDATE prefixing the character @
to the file name that contains the sparql update script, e.g.:
SD_SPARQL_UPDATE @myscript.ru
To ingest data, you can use the powerful SD_LEARN command. For instance to load the whole definition of schema.org just type:
SD_LEARN https://schema.org/version/3.4/schema.ttl
This command will create a graph named "http://schema.org/version/3.4/schema.ttl" in your knowledge base, populating it with the content extracted from http://schema.org/version/3.4/schema.ttl plus all metadata.
You can also give a different name to the ingested graph:
SD_LEARN http://schema.org https://schema.org/version/3.4/schema.ttl
SD_LEARN supports a lot of options to load one or more local or remote files (also mixed) in a single graph and applying optional transformations before loading. SD_LEARN implements a full ETL (extract transform and load) process, and it is one of the core commands of the SDaaS Platform.
To query the store you can use SPARQL:
SD_SPARQL_QUERY text/csv 'SELECT DISTINCT ?class WHERE { ?s a ?class}'
This command prints a table with all classes related to a subject in your knowledge base. The first argument specifies the format you want for the result.
You can also pass a file to SD_SPARQL_QUERY prefixing the character @
to the file name that contains the SPARQL update script, e.g.:
Some shortcuts are available. For example, in this command:
SD_SPARQL_QUERY csv-h @myquery.rq
csv-h is a shortcut for text/csv without headers.
Another useful command is SD_EVAL_CONSTRUCTOR that allows materializing the result of an n axiom expressed with a SPARQL QUERY Construct operation.
SD_EVAL_CONSTRUCTOR accepts a URI for the graph name to be created and a string with a SPARQL construct or a file (prefixed by @) or an URL of a resource resulting in a SPARQL construct. E.g.:
SD_EVAL_CONSTRUCTOR urn:myreasoning:silly 'CONSTRUCT {?class a <urn:tbox:element>} WHERE {?s a ?class}'
now you can query:
SD_SPARQL_QUERY csv-h 'SELECT DISTINCT ?class WHERE {?class a <urn:tbox:element>} LIMIT 3'
Finally, you can create a script (for instance named build.sdaas) with some commands, e.g.:
SD_LEARN https://schema.org/version/3.4/schema.ttl
SD_EVAL_CONSTRUCTOR urn:myreasoning:silly 'CONSTRUCT {?class a <urn:tbox:element>} WHERE {?s a ?class}'
SD_THATS_ALL_FOLKS
source
command inside sdaas or using -f filename
from SDaaS CLI options.
Updated