Initial support for jena rules. not working.
This commit is contained in:
parent
31b3a144fc
commit
2ab7204966
|
@ -30,7 +30,8 @@
|
|||
:Switch a :PortableGameConsole ;
|
||||
:madeBy :Nintendo ;
|
||||
:releaseYear 2017 ;
|
||||
rev:hasReview :SwitchReviewByJPT .
|
||||
rev:hasReview :SwitchReviewByJPT;
|
||||
:hasPrice 329 .
|
||||
|
||||
:Playstation4 a :GameConsole .
|
||||
|
||||
|
@ -44,4 +45,4 @@
|
|||
rev:reviewer :JPT ;
|
||||
rev:text "Yet another gaming console. I lost a tetris game once. Meh."^^xsd:string .
|
||||
|
||||
:Switch :hasPrice "329,00"^^:PriceEur .
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
@prefix : <http://example.com/ins_uebung/#> .
|
||||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
|
||||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
||||
@prefix rev: <http://purl.org/stuff/rev#> .
|
||||
@prefix owl: <http://www.w3.org/2002/07/owl#> .
|
||||
|
||||
[rule1: (?con rdf:type :GameConsole) (?con :predecessorOfConsole ?otherCon)
|
||||
noValue(?otherCon :successorOfConsole ?con)
|
||||
-> (?otherCon :successorOfConsole ?con)]
|
||||
|
||||
[rule2: (?con :hasPrice ?someValue)
|
||||
-> remove(?con :hasPrice ?someValue)]
|
||||
|
||||
[rule3: (?con rev:hasReview ?rev) (?rev rev:reviewer ?reviewer)
|
||||
-> (?reviewer :hasReviewedConsole ?con)]
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
:hasPrice rdf:type rdf:Property ;
|
||||
rdfs:domain :GameConsole ;
|
||||
rdfs:range :xsd:string .
|
||||
rdfs:range xsd:int .
|
||||
|
||||
# rdfs:Datatype
|
||||
:PriceEur rdf:type rdfs:Datatype .
|
||||
|
|
|
@ -22,6 +22,8 @@ import org.apache.jena.reasoner.Reasoner;
|
|||
import org.apache.jena.reasoner.ReasonerRegistry;
|
||||
import org.apache.jena.reasoner.ValidityReport;
|
||||
import org.apache.jena.reasoner.ValidityReport.Report;
|
||||
import org.apache.jena.reasoner.rulesys.GenericRuleReasoner;
|
||||
import org.apache.jena.reasoner.rulesys.Rule;
|
||||
import org.apache.jena.util.FileManager;
|
||||
import org.apache.jena.util.PrintUtil;
|
||||
|
||||
|
@ -45,12 +47,17 @@ public class App {
|
|||
// Let's create an owl reasoner
|
||||
Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
|
||||
reasoner = reasoner.bindSchema(tboxModel);
|
||||
OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
|
||||
ontModelSpec.setReasoner(reasoner);
|
||||
//OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
|
||||
//ontModelSpec.setReasoner(reasoner);
|
||||
InfModel infModel = ModelFactory.createInfModel(reasoner, aboxModel);
|
||||
|
||||
validate(infModel);
|
||||
reasoner = new GenericRuleReasoner(Rule.rulesFromURL("data/jenarules.txt"));
|
||||
infModel = ModelFactory.createInfModel(reasoner, aboxModel);
|
||||
|
||||
validate(infModel);
|
||||
|
||||
printResource(infModel, "JPT");
|
||||
printResource(infModel, "Wii");
|
||||
printResource(infModel, "Wii_u");
|
||||
printResource(infModel, "Switch");
|
||||
|
|
Loading…
Reference in New Issue