Does virtuoso support reasoning and inference.?
I'm using virtuoso open-source for my college project and I have been trying to do rdfs reasoning on a sample dataset
@prefix : <http://example.com/ont#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:Person a rdfs:Class ;
rdfs:label "Person" .
:Man a rdfs:Class ;
rdfs:subClassOf :Person ;
rdfs:label "Man" .
:Woman a rdfs:Class ;
rdfs:subClassOf :Person ;
rdfs:label "Woman" .
:likes a rdf:Property ;
rdfs:domain :Person ;
rdfs:range :Person ;
rdfs:label "likes" .
:John a :Man ;
:likes :Mary .
:Mary a :Woman .
I want to add new triplets Jhon rdfs:type Person and Mary rdfs:type Person, I tried a SPARQL query
SPARQL
@prefix : <http://example.com/ont#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
INSERT INTO GRAPH <http://example.com/ont#>
{
?person rdfs:type ?cls .
}
WHERE
{
GRAPH <http://example.com/ont#>
{
:Man rdfs:subClassOf ?cls .
?person rdfs:type :Man .
:Woman rdfs: subClassOf ?cls .
?person rdfs:type :Woman .
}
}
When I run the isql shell it runs successfully but it doesn't insert any triplets in the graph, I'm a little confused here, can you guys please help me out.?
When I attempt to run your query it is failing with the error:
SQL> SPARQL @prefix : <http://example.com/ont#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . INSERT INTO GRAPH <http://example.com/ont#> { ?person rdfs:type ?cls . } WHERE { GRAPH <http://example.com/ont#> { :Man rdfs:subClassOf ?cls . ?person rdfs:type :Man . :Woman rdfs: subClassOf ?cls . ?person rdfs:type :Woman . } };
*** Error 37000: VD [Virtuoso Server]SQ074: Line 1: SP030: SPARQL compiler, line 1: syntax error at 'subClassOf' before '?cls' at ';' immediately before end of statement
at line 20 of Top-Level:
SPARQL @prefix : <http://example.com/ont#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . INSERT INTO GRAPH <http://example.com/ont#> { ?person rdfs:type ?cls . } WHERE { GRAPH <http://example.com/ont#> { :Man rdfs:subClassOf ?cls . ?person rdfs:type :Man . :Woman rdfs: subClassOf ?cls . ?person rdfs:type :Woman . } }
SQL>
Thus is the query correct?
Note you should include query text around verbatim tags such that query is passed as is with nothing stripped out as I had to add missing < and > chars to your query and TTL file to correct them ...
Virtuoso supports reasoning and inference. Your example is handled via built-in inference rules using terms from RDF Schema (or RDFS).
Here's an end-to-end example from our Github repo.