[TASK] Enhance Main.java for static knowledge.
This commit is contained in:
parent
f49110eaef
commit
935263862e
|
@ -6,6 +6,7 @@ import org.apache.log4j.PropertyConfigurator;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import eu.larkc.csparql.common.utils.CsparqlUtils;
|
||||||
import eu.larkc.csparql.core.engine.ConsoleFormatter;
|
import eu.larkc.csparql.core.engine.ConsoleFormatter;
|
||||||
import eu.larkc.csparql.core.engine.CsparqlEngine;
|
import eu.larkc.csparql.core.engine.CsparqlEngine;
|
||||||
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
import eu.larkc.csparql.core.engine.CsparqlEngineImpl;
|
||||||
|
@ -31,7 +32,22 @@ public class Main {
|
||||||
// Instantiate and initialize engine
|
// Instantiate and initialize engine
|
||||||
CsparqlEngine engine = new CsparqlEngineImpl();
|
CsparqlEngine engine = new CsparqlEngineImpl();
|
||||||
engine.initialize(true);
|
engine.initialize(true);
|
||||||
|
|
||||||
|
// Add static knowledge into local graph from file
|
||||||
|
try {
|
||||||
|
//engine.putStaticNamedModel("http://streamreasoning.org/roomConnection", CsparqlUtils.serializeRDFFile("examples_files/roomConnection.rdf"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(e.toString());
|
||||||
|
logger.error(e.getStackTrace().toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use a SPARQL Query to update the local knowledge from code instead of using CONSTRUCT within the engine.
|
||||||
|
String updateQuery = "PREFIX : <http://www.streamreasoning.org/ontologies/sr4ld2014-onto#> "
|
||||||
|
+ "INSERT DATA "
|
||||||
|
+ "{ GRAPH <http://streamreasoning.org/roomConnection> { :room :isConnectedTo :room2 } }";
|
||||||
|
engine.execUpdateQueryOverDatasource(updateQuery);
|
||||||
|
*/
|
||||||
|
|
||||||
// Debugging: Needed to verify which engine is being used
|
// Debugging: Needed to verify which engine is being used
|
||||||
//logger.debug("CWD: " + System.getProperty("user.dir"));
|
//logger.debug("CWD: " + System.getProperty("user.dir"));
|
||||||
//logger.debug("Engine from: " + engine.getClass().getProtectionDomain().getCodeSource());
|
//logger.debug("Engine from: " + engine.getClass().getProtectionDomain().getCodeSource());
|
||||||
|
@ -52,9 +68,9 @@ public class Main {
|
||||||
CsparqlQueryResultProxy resultProxy = null;
|
CsparqlQueryResultProxy resultProxy = null;
|
||||||
try {
|
try {
|
||||||
resultProxy = engine.registerQuery(query, true);
|
resultProxy = engine.registerQuery(query, true);
|
||||||
} catch (ParseException e1) {
|
} catch (ParseException e) {
|
||||||
logger.error(e1.toString());
|
logger.error(e.toString());
|
||||||
logger.error(e1.getStackTrace().toString());
|
logger.error(e.getStackTrace().toString());
|
||||||
}
|
}
|
||||||
// Add ConsoleFormatter as observer so it gets notified of every query result
|
// Add ConsoleFormatter as observer so it gets notified of every query result
|
||||||
resultProxy.addObserver(new ConsoleFormatter());
|
resultProxy.addObserver(new ConsoleFormatter());
|
||||||
|
|
Loading…
Reference in New Issue