70 likes | 204 Views
OWL Inferencing – don ’ t copy this demo from a PDF, it won ’ t work – use the PPT file instead. -- If you don ’ t have an RDS_DATA_TABLE in your user account, uncomment the following two lines the first time you run this. -- CREATE TABLE RDF_DATA_TABLE( id NUMBER, triple SDO_RDF_TRIPLE_S);
E N D
OWL Inferencing – don’t copy this demo from a PDF, it won’t work – use the PPT file instead -- If you don’t have an RDS_DATA_TABLE in your user account, uncomment the following two lines the first time you run this. -- CREATE TABLE RDF_DATA_TABLE( id NUMBER, triple SDO_RDF_TRIPLE_S); -- EXEC SEM_APIS.CREATE_RDF_MODEL('RDF_MODEL_CS345_UTEId', 'RDF_DATA_TABLE', 'triple'); TRUNCATE TABLE "RDF_DATA_TABLE" drop storage; DROP SEQUENCE RDF_DATA_TABLE_SQNC; CREATE SEQUENCE RDF_DATA_TABLE_SQNC START WITH 1 NOCACHE; INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#OBJECT>', 'rdf:type', 'rdfs:Class')); INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#ANIMAL>', 'rdf:type', 'rdfs:Class'));
OWL Inferencing INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#ANIMAL>', 'rdfs:subClassOf', '<http://www.example.org/people.owl#OBJECT>')); INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#CAT>', 'rdf:type', 'rdfs:Class')); INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#CAT>', 'rdfs:subClassOf', '<http://www.example.org/people.owl#ANIMAL>')); INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#i5>', 'rdf:type', '<http://www.example.org/people.owl#CAT>')); INSERT INTO RDF_DATA_TABLE VALUES ( RDF_DATA_TABLE_SQNC.nextval, SDO_RDF_TRIPLE_S('RDF_MODEL_CS345_PROF1:<http://www.example.org/people.owl>', '<http://www.example.org/people.owl#i5>', '<http://www.example.org/people.owl#value>', '"101"^^xsd:integer')); Commit;
OWL Inferencing -- named graph local inference (NGLI) BEGIN sem_apis.create_entailment( 'RDF_ENT_CS345_PROF1', models_in => sem_models('RDF_MODEL_CS345_PROF1'), rulebases_in => sem_rulebases('owl2rl'), passes => SEM_APIS.REACH_CLOSURE, inf_components_in => null, options => 'LOCAL_NG_INF=T' ); END; /
OWL Inferencing select g, s, p, o from table(sem_match('{graph ?g {?s ?p ?o}}', sem_models('RDF_MODEL_CS345_PROF1'),sem_rulebases('owl2rl'),null,null)) MINUS select g, s, p, o from table(sem_match('{graph ?g {?s ?p ?o}}', sem_models('RDF_MODEL_CS345_PROF1'),null,null,null)) Returns: http://www.example.org/people.owl http://www.example.org/people.owl#CAT http://www.w3.org/2000/01/rdf-schema#subClassOf http://www.example.org/people.owl#OBJECT http://www.example.org/people.owl http://www.example.org/people.owl#i5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.example.org/people.owl#ANIMAL http://www.example.org/people.owl http://www.example.org/people.owl#i5 http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.example.org/people.owl#OBJECT
OWL Inferencing SEM_MODELS('RDF_MODEL_CS345_prof1'), null, SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) SELECT value from table( sem_match('select * where { ?indiv rdf:type :CAT. ?indiv :value ?value . }', SEM_MODELS('RDF_MODEL_CS345_prof1'), sem_rulebases('owl2rl'), SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) Returns: Value 101
OWL Inferencing SEM_MODELS('RDF_MODEL_CS345_prof1'), null, SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) SELECT value from table( sem_match('select * where { ?indiv rdf:type :ANIMAL. ?indiv :value ?value . }', SEM_MODELS('RDF_MODEL_CS345_prof1'), sem_rulebases('owl2rl'), SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) Returns: Value 101
OWL Inferencing SEM_MODELS('RDF_MODEL_CS345_prof1'), null, SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) SELECT value from table( sem_match('select * where { ?indiv rdf:type :OBJECT. ?indiv :value ?value . }', SEM_MODELS('RDF_MODEL_CS345_prof1'), sem_rulebases('owl2rl'), SEM_ALIASES( SEM_ALIAS('', 'http://www.example.org/people.owl#')), null) ) Returns: Value 101