diff --git a/data/abox.ttl b/data/abox.ttl index 5f4ba8f..1f52251 100644 --- a/data/abox.ttl +++ b/data/abox.ttl @@ -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 . + diff --git a/data/jenarules.txt b/data/jenarules.txt new file mode 100644 index 0000000..d1cf1aa --- /dev/null +++ b/data/jenarules.txt @@ -0,0 +1,17 @@ +@prefix : . +@prefix rdf: . +@prefix xsd: . +@prefix rdfs: . +@prefix foaf: . +@prefix rev: . +@prefix 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)] \ No newline at end of file diff --git a/data/tbox.ttl b/data/tbox.ttl index 6682b87..0668fc1 100644 --- a/data/tbox.ttl +++ b/data/tbox.ttl @@ -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 . diff --git a/src/main/java/hsh/ins_jena/App.java b/src/main/java/hsh/ins_jena/App.java index 4d5a920..3607fdb 100644 --- a/src/main/java/hsh/ins_jena/App.java +++ b/src/main/java/hsh/ins_jena/App.java @@ -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");