[TASK] Add NOTA pattern.

This commit is contained in:
Jan Philipp Timme 2016-10-01 19:17:36 +02:00
parent de2d6fa64a
commit 48e01f493f
2 changed files with 50 additions and 2 deletions

View File

@ -71,7 +71,7 @@ public class Main {
testGeneratorThread.start();
// Now build a query to run - interchangeable
String query = Main.getTestPatternQuery();
String query = Main.getNOTA();
//String query = RentACarSimulation.getEventUsingBackgroundKnowledge();
// Create a result proxy by registering the query at the engine
@ -135,6 +135,54 @@ public class Main {
+ "}";
}
/*
* WHERE {
OPTIONAL {
?eventA rdf:type <http://example.org/type/A> .
}
OPTIONAL {
?eventB rdf:type <http://example.org/type/B> .
}
FILTER((BOUND(?eventA) || BOUND(?eventB))
&& NOT (BOUND(?eventA) && BOUND(?eventB)))
}
* */
private static String getAXORB() {
return "REGISTER QUERY matchAXORB AS "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
+ "SELECT ?atype ?btype "
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
+ "WHERE { "
+ " OPTIONAL { "
+ " ?a a <http://example.org/type/A> . "
+ " ?a a ?atype . "
+ " } "
+ " OPTIONAL { "
+ " ?b a <http://example.org/type/B> . "
+ " ?b a ?btype . "
+ " } "
+ " FILTER( (BOUND(?a) || BOUND(?b)) && !(BOUND(?a) && BOUND(?b)) ) "
+ "}";
}
private static String getNOTA() {
return "REGISTER QUERY matchNOTA AS "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> "
+ "PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> "
+ "SELECT ?anyEventType "
+ "FROM STREAM <http://example.org> [RANGE 5s STEP 1s] "
+ "WHERE { "
+ " ?anyEvent a ?anyEventType . "
+ " OPTIONAL { "
+ " ?eventA a <http://example.org/type/A> . "
+ " } "
+ " FILTER(!BOUND(?eventA)) "
+ "}";
}
private static String getTestPatternQuery() {
return "REGISTER QUERY matchANotBC AS "
+ "PREFIX f: <http://larkc.eu/csparql/sparql/jena/ext#> "

View File

@ -37,7 +37,7 @@ public class TestStreamGenerator extends RdfStream implements Runnable {
);
try {
Thread.sleep(100);
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}