Minor changes

This commit is contained in:
Maschell 2018-01-02 13:48:40 +01:00
parent 18da088ea1
commit 31b3a144fc
3 changed files with 49 additions and 34 deletions

View File

@ -5,38 +5,42 @@
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rev: <http://purl.org/stuff/rev#> .
:Kimishima rdf:type foaf:Person ;
:Kimishima a foaf:Person ;
foaf:familyName "Kimishima"^^xsd:string ;
foaf:givenName "Tatsumi"^^xsd:string .
:Wii rdf:type :GameConsole .
:Wii a :GameConsole .
:Wii :releaseYear 2006 .
:Wii :madeBy :Nintendo .
:Nintendo rdf:type foaf:Organization ;
:Nintendo a foaf:Organization ;
:ceo :Kimishima ;
:foundingYear 1889 ;
foaf:name "Nintendo Co., Ltd."^^xsd:string .
:Wii_u rdf:type :GameConsole ;
:Wii_u a :GameConsole ;
:internetEnabled true ;
:consoleName "Wii U"^^xsd:string ;
:numOfSupportedControllers 8 ;
:numOfSupportedControllers 8;
:predecessorOfConsole :Wii ;
:releaseYear 2012 ;
:madeBy :Nintendo ;
:successorOfConsole :Switch .
:Switch rdf:type :PortableGameConsole .
:Switch :madeBy :Nintendo .
:Switch rev:hasReview :SwitchReviewByJPT .
:Switch a :PortableGameConsole ;
:madeBy :Nintendo ;
:releaseYear 2017 ;
rev:hasReview :SwitchReviewByJPT .
:Playstation4 a :GameConsole .
:JPT rdf:type foaf:Person ;
foaf:name "Jan Philipp Timme"^^xsd:string .
:Maschell rdf:type foaf:Person ;
:Maschell a foaf:Person ;
foaf:name "Marcel Felix"^^xsd:string .
:SwitchReview rdf:type rev:Review ;
:SwitchReview a rev:Review ;
rev:reviewer :JPT ;
rev:text "Yet another gaming console. I lost a tetris game once. Meh."^^xsd:string .

View File

@ -62,27 +62,28 @@
:successorOfConsole rdfs:subPropertyOf :relatedToConsole .
# rdfs:subClassOf
:PortableGameConsole rdf:type rdfs:Class .
:GameConsole rdf:type rdfs:Class .
:PortableGameConsole a rdfs:Class .
:GameConsole a rdfs:Class .
:PortableGameConsole rdfs:subClassOf :GameConsole .
:HomeConsole owl:equivalentClass [
rdf:type owl:Class ;
owl:intersectionOf (
:GameConsole [owl:complementOf :PortableGameConsole]
:GameConsole [
owl:complementOf :PortableGameConsole
]
)
] .
:NintendoConsole owl:equivalentClass [
rdf:type owl:Restriction ;
owl:onProperty :madeBy ;
owl:someValuesFrom :Nintendo
owl:hasValue :Nintendo
] .
:PartyConsole rdf:equivalentClass [
:PartyConsole owl:equivalentClass [
rdf:type owl:Restriction ;
owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ;
owl:minQualifiedCardinality "1"^^xsd:nonNegativeInteger ;
owl:onProperty :numOfSupportedControllers ;
owl:onClass :GameConsole
] .

View File

@ -1,8 +1,11 @@
package hsh.ins_jena;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Iterator;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
@ -28,12 +31,12 @@ public class App {
public static String OUTPUT_PATH = "./output";
public static String SPARQL_ENDPOINT = "http://localhost:3030/test/query";
public static void main(String[] args) {
public static void main(String[] args) throws IOException {
generateFiles(OUTPUT_PATH);
readAndHandleFiles(OUTPUT_PATH);
}
private static void readAndHandleFiles(String inputPath) {
private static void readAndHandleFiles(String inputPath) throws IOException {
// Model tboxModel = FileManager.get().loadModel("file:" + inputPath + "/" Generator.T_BOX_FILENAME_XML);
// Model aboxModel = FileManager.get().loadModel("file:" + inputPath + "/" Generator.A_BOX_FILENAME_XML);
Model tboxModel = FileManager.get().loadModel("file:" + "data/tbox.ttl");
@ -44,19 +47,12 @@ public class App {
reasoner = reasoner.bindSchema(tboxModel);
OntModelSpec ontModelSpec = OntModelSpec.OWL_DL_MEM_RULE_INF;
ontModelSpec.setReasoner(reasoner);
InfModel infModel = ModelFactory.createOntologyModel(ontModelSpec, aboxModel);
InfModel infModel = ModelFactory.createInfModel(reasoner, aboxModel);
ValidityReport validity = infModel.validate();
if (validity.isValid()) {
System.out.println("Validation: OK");
} else {
System.out.println("Conflicts");
for (Iterator<Report> i = validity.getReports(); i.hasNext();) {
ValidityReport.Report report = (ValidityReport.Report) i.next();
System.out.println(" - " + report);
}
}
validate(infModel);
printResource(infModel, "Wii");
printResource(infModel, "Wii_u");
printResource(infModel, "Switch");
printResource(infModel, "HomeConsole");
printResource(infModel, "PartyConsole");
@ -102,8 +98,8 @@ public class App {
//@formatter:on
// Let's execute one query and print its results
QueryExecution queryExecLocalConsoles = QueryExecutionFactory.create(queryAll, infModel);
System.err.println("Show consoles from local model");
//QueryExecution queryExecLocalConsoles = QueryExecutionFactory.create(queryAll, infModel);
//System.err.println("Show consoles from local model");
// printQueryResult(queryExecLocalConsoles);
QueryExecution queryExecNintendoConsoles = QueryExecutionFactory.create(queryNintendoConsoles, infModel);
@ -128,6 +124,20 @@ public class App {
printQueryConstructs(queryExecRemoteCEOtoConsole);
}
private static void validate(InfModel model) {
ValidityReport validity = model.validate();
if (validity.isValid()) {
System.out.println("Validation: OK");
} else {
System.out.println("Conflicts");
for (Iterator<Report> i = validity.getReports(); i.hasNext();) {
ValidityReport.Report report = (ValidityReport.Report) i.next();
System.out.println(" - " + report);
}
}
}
private static void printResource(Model model, String resource) {
Resource nForce = model.getResource("http://example.com/ins_uebung/#" + resource);
System.out.println(resource + "*:");