Last active
September 11, 2015 19:37
-
-
Save edgarRd/6be62cba73d97640cca0 to your computer and use it in GitHub Desktop.
RDF dataset in TriG for Vehicles - Reasoning & Stardog Rules example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sample obtained from: | |
# http://www.dotnetrdf.org/content.asp?pageID=Inference%20and%20Reasoning | |
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . | |
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . | |
@prefix vh: <http://example.org/vehicles/> . | |
@prefix : <http://myvehicledata.com/> . | |
@prefix rule: <tag:stardog:api:rule:> . | |
# Tbox | |
vh:schema | |
{ | |
vh:Vehicle a owl:Class . | |
vh:Car rdfs:subClassOf vh:Vehicle . | |
vh:SportsCar rdfs:subClassOf vh:Car . | |
vh:LatestModel a owl:Class . | |
vh:OldModel a owl:Class . | |
# throwing some rules here | |
[] a rule:SPARQLRule ; | |
rule:content """ | |
PREFIX vh: <http://example.org/vehicles/> | |
IF { | |
?v a vh:Vehicle ; | |
vh:yearModel ?year . | |
bind(year(now()) - ?year as ?yearDiff) . | |
FILTER(?yearDiff = 0) . | |
} | |
THEN { | |
?v a vh:LatestModel . | |
} | |
""" . | |
[] a rule:SPARQLRule ; | |
rule:content """ | |
PREFIX vh: <http://example.org/vehicles/> | |
IF { | |
?v a vh:Vehicle ; | |
vh:yearModel ?year . | |
bind(year(now()) - ?year as ?yearDiff) . | |
FILTER(?yearDiff > 10) . | |
} | |
THEN { | |
?v a vh:OldModel . | |
} | |
""" . | |
} | |
# default graph contains Abox data | |
{ | |
:car1 a vh:Car ; | |
vh:yearModel "2001"^^xsd:int . | |
:car2 a vh:Car ; | |
vh:yearModel "2015"^^xsd:int . | |
:car3 a vh:SportsCar ; | |
vh:yearModel "2009"^^xsd:int . | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment