Homework Assignment # 5
Due Wednesday October 24, 2012 by 11:59 pm + 1 minute (Midnight). Use turnin to submit your homework (i.e., turnin -submit [MW use swati, TTh use benself] CS345_HW5 Python.g PyTuple.java)
Please include your EID in every file of your homework. If you do not include your EID in every file, you will receive a 0. It will be as if you did not submit it. If the file is code, include your EID as a comment at the top of the file. If it's not code, put your EID at the top of the file.
1. [10 Points] Modify the ReL language to have an ENTAIL statement. This statement will execute the create_entailment procedure found on page 3 of the Inferencing notes.
Hints:
To modify Python.g,
Add
| sparql_stmt
-> sparql_stmt
after
| sim_stmt
-> sim_stmt
in the "atom" non-terminal.
Flesh out the sparql _stmt non-terminal in a manner similar to a sql or sim statement (it, of course, is much simpler because it is just one Terminal). The call to the Tuple constructor can pass the following arguments:
$sparql_stmt.start, null, $expr::ctype, $sparql_stmt::strings, "SPARQL"
Add the ENTAIL Terminal near the bottom of the file.
To modify PyTuple.java,
Find the "if (mode.equals("SIM")) {" statement
Add the condition:
} else if (mode.equals("SPARQL")) {
this.sDoer = new SPARQLDoer(conn, uname);
sDoer.executeStatement("BEGIN \n" +
"sem_apis.create_entailment( \n" +
" 'RDF_ENT_CS345_UTEid', \n" +
" models_in => sem_models('RDF_MODEL_CS345_UTEid'), \n" +
" rulebases_in => sem_rulebases('owl2rl'), \n" +
" passes => SEM_APIS.REACH_CLOSURE, \n" +
" options => 'LOCAL_NG_INF=T' \n" +
"); \n" +
"END; \n");
To test the ENTAIL statement, put ENTAIL at the bottom of the tests/SIMDemo.py file, run dist/bin/jython tests/SIMDemo.py and then, in SQLDeveloper, execute the query found in the Inferencing notes on page 4 (use the ppt version). You should see over 190 entailments.