Difference between revisions of "Singleton Property Reasoning"
From Knoesis wiki
m |
|||
Line 79: | Line 79: | ||
set timing on | set timing on | ||
− | create table stable_lubmsp_500 ( RDF$STC_sub varchar2(4000) not null, RDF$STC_pred varchar2(4000) not null, RDF$STC_obj varchar2(4000) not null); | + | create table stable_lubmsp_500 ( RDF$STC_sub varchar2(4000) not null, RDF$STC_pred varchar2(4000) not null, |
+ | RDF$STC_obj varchar2(4000) not null); | ||
grant SELECT on stable_lubmsp_500 to MDSYS; | grant SELECT on stable_lubmsp_500 to MDSYS; | ||
− | CREATE TABLE RDF$ET_TAB_LUBMSP_500 ( proc_sid VARCHAR2(30), proc_sig VARCHAR2(200), event_name varchar2(200), start_time timestamp, end_time timestamp, start_comment varchar2(1000) DEFAULT NULL, end_comment varchar2(1000) DEFAULT NULL ); | + | CREATE TABLE RDF$ET_TAB_LUBMSP_500 ( proc_sid VARCHAR2(30), proc_sig VARCHAR2(200), event_name varchar2(200), start_time |
+ | timestamp, end_time timestamp, start_comment varchar2(1000) DEFAULT NULL, end_comment varchar2(1000) DEFAULT NULL ); | ||
GRANT INSERT on RDF$ET_TAB_LUBM_500 to MDSYS; | GRANT INSERT on RDF$ET_TAB_LUBM_500 to MDSYS; | ||
− | host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/LUBM_500_sp.nt direct=true rows=10000000 skip_index_maintenance=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad discard=d0.rej log=d0.log errors=1000000 | + | host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/LUBM_500_sp.nt |
+ | direct=true rows=10000000 skip_index_maintenance=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad | ||
+ | discard=d0.rej log=d0.log errors=1000000 | ||
− | host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/lubmsp_onto.nt direct=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad discard=d0.rej log=d0.log errors=1000000 | + | host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/lubmsp_onto.nt |
+ | direct=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad discard=d0.rej log=d0.log errors=1000000 | ||
commit; | commit; | ||
Line 99: | Line 104: | ||
grant INSERT,UPDATE on atab_lubmsp_500 to MDSYS; | grant INSERT,UPDATE on atab_lubmsp_500 to MDSYS; | ||
− | exec sem_apis.bulk_load_from_staging_table(model_name=>'LUBMSP_500_MODEL', table_owner=>' | + | exec sem_apis.bulk_load_from_staging_table(model_name=>'LUBMSP_500_MODEL', table_owner=>'user', table_name=>'stable_lubmsp_500'); |
commit; | commit; |
Revision as of 11:29, 4 May 2015
Contents
Downloads
The packages are available for download at sourceforge.net
LUBM-SP: http://sourceforge.net/projects/graphke/files/lubmsp_1.0.0.jar/download
LUBM-SP ontology: http://sourceforge.net/projects/graphke/files/lubmsp_onto.nt/download
SPARQL queries http://sourceforge.net/projects/graphke/files/queries.tar.gz/download
Jena Query evaluation http://sourceforge.net/projects/graphke/files/lubmsp_query_eval_1.0.0.jar/download
Instructions
Setting up files
1. mkdir lubmsp 2. cd lubmsp 3. Download all the files provided in the Download section above into this folder 4. tar -xzvf queries.tar.gz 5. You may want to install the rlwrap package for command history
Here we explain the step-by-step to generate the LUBM-SP datasets, and run the query evaluation
Generating LUBM and LUBM-SP datasets
1. cd lubmsp 2. Run the code, the number of university may be 50, 500, or 1000 java -jar lubmsp_1.0.0.jar -univ 500 -index 0 -onto http://knoesis.org/lubmsp 3. Check for three data files generated LUBM_500.nt: the original LUBM in the form of ntriples LUBM_500_sp.nt: the LUBM-SP in the form of ntriples LUBM_500.rdf: the original LUBM in the form of RDF/XML
Query evaluation in Jena
1. cd lubmsp 2. java -jar lubmsp_query_eval_1.0.0.jar or rlwrap java -jar lubmsp_query_eval_1.0.0.jar reasoner: rdfs ontology: lubmsp_onto.nt instances: LUBM_500_sp.nt query: queries/lubm_query1.sparql
Preparing Oracle 12c
1. Download and install Oracle database 12c to $ORACLE_HOME 2. Download and install Oracle client: sqlplus 3. Create one Oracle instance using dbca 4. Connect to sqlplus sqlplus / as sysdba 5. Execute the two files $ORACLE_HOME/md/admin/catsem.sql and $ORACLE_HOME/md/admin/sdordfwm.sql SQL> @'?/md/admin/catsem.sql' SQL> @'?/md/admin/sdordfwm.sql' 6. Create a tablespace rdf_tblspace 7. Create a semantic network on the tablespace rdf_tblspace
Loading data to Oracle 12c
There are different ways to load data into Oracle. Here we use the bulk load from staging table method.
Below is the sample code for loading LUBM_500_sp.nt to Oracle
connect user/pass set timing on create table stable_lubmsp_500 ( RDF$STC_sub varchar2(4000) not null, RDF$STC_pred varchar2(4000) not null, RDF$STC_obj varchar2(4000) not null); grant SELECT on stable_lubmsp_500 to MDSYS; CREATE TABLE RDF$ET_TAB_LUBMSP_500 ( proc_sid VARCHAR2(30), proc_sig VARCHAR2(200), event_name varchar2(200), start_time timestamp, end_time timestamp, start_comment varchar2(1000) DEFAULT NULL, end_comment varchar2(1000) DEFAULT NULL ); GRANT INSERT on RDF$ET_TAB_LUBM_500 to MDSYS; host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/LUBM_500_sp.nt direct=true rows=10000000 skip_index_maintenance=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad discard=d0.rej log=d0.log errors=1000000 host sqlldr userid=user/pass control=/path/to/lubmsp/bulkload_lubmsp_500.ctl data=/path/to/lubmsp/lubmsp_onto.nt direct=true skip=0 load=1000000000 discardmax=1000000 bad=d0.bad discard=d0.rej log=d0.log errors=1000000 commit; create table atab_lubmsp_500 (triple sdo_rdf_triple_s); exec sem_apis.create_sem_model('LUBMSP_500_MODEL', 'ATAB_LUBMSP_500', 'TRIPLE'); grant INSERT,UPDATE on atab_lubmsp_500 to MDSYS; exec sem_apis.bulk_load_from_staging_table(model_name=>'LUBMSP_500_MODEL', table_owner=>'user', table_name=>'stable_lubmsp_500'); commit; select count(*) from table(sem_match('{?s ?p ?o}', SEM_MODELS('LUBMSP_500_MODEL'), NULL, NULL, NULL)); INSERT INTO ATAB_LUBMSP_500 VALUES ( SDO_RDF_TRIPLE_S('LUBMSP_500_MODEL', '<http://www.w3.org/1999/02/22-rdf-syntax-ns#singletonPropertyOf>', '<http://www.w3.org/2000/01/rdf-schema#subPropertyOf>', '<http://www.w3.org/2000/01/rdf-schema#subPropertyOf>')); commit; EXEC SEM_APIS.CREATE_ENTAILMENT('rdfs_rix_lubmsp_500', SEM_Models('LUBMSP_500_MODEL'), SEM_Rulebases('RDFS')); commit;
This is an example of the control file for bulkload_lubmsp_500.ctl
UNRECOVERABLE LOAD DATA APPEND into table stable_lubmsp_500 when (1) <> '#' ( RDF$STC_sub CHAR(4000) terminated by whitespace "( CASE WHEN substr(:RDF$STC_sub,1,1)='<' AND substr(:RDF$STC_sub,-1,1)='>' AND length(:RDF$STC_sub)>2 THEN :RDF$STC_sub WHEN substr(:RDF$STC_sub,1,2)='_:' AND REGEXP_LIKE(:RDF$STC_sub,'^(_:)[[:alpha:]][[:alnum:]]*$') THEN :RDF$STC_sub WHEN substr(:RDF$STC_sub,1,1) NOT IN ('\"','<','#') AND substr(:RDF$STC_sub,-1,1) NOT IN ('\"','>') THEN ('<' || SDO_RDF.replace_rdf_prefix(:RDF$STC_sub) || '>') WHEN substr(:RDF$STC_sub,1,1)='#' THEN SDO_RDF.raise_parse_error( 'Ignored Comment Line starting with ', :RDF$STC_sub) ELSE SDO_RDF.raise_parse_error('Invalid Subject', :RDF$STC_sub) END )", RDF$STC_pred CHAR(4000) terminated by whitespace "( CASE WHEN substr(:RDF$STC_pred,1,1)='<' AND substr(:RDF$STC_pred,-1,1)='>' AND length(:RDF$STC_pred)>2 THEN :RDF$STC_pred WHEN substr(:RDF$STC_pred,1,2) != '_:' AND substr(:RDF$STC_pred,1,1) NOT IN ('\"','<') AND substr(:RDF$STC_pred,-1,1) NOT IN ('\"','>') THEN ('<' || SDO_RDF.replace_rdf_prefix(:RDF$STC_pred) || '>') ELSE SDO_RDF.raise_parse_error('Invalid Predicate', :RDF$STC_pred) END )", -- -- right-trimming of WHITESPACEs is reqd for "RDF$STC_obj" -- (due to absence of "TERMINATED BY WHITESPACE") -- -- For ease of editing below replace -- "rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13))" with ":xy". -- and then replace back -- RDF$STC_obj CHAR(5000) "( CASE WHEN substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,1)='<' AND substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),-1,1)='>' AND length(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)))>2 THEN rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)) WHEN substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,1)='\"' AND substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),-1,1)='\"' AND length(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)))>1 THEN rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)) WHEN substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,2)='_:' AND REGEXP_LIKE(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)), '^(_:)[[:alpha:]][[:alnum:]]*$') THEN rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)) WHEN substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,1) NOT IN ('\"','<') AND substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),-1,1) NOT IN ('\"','>') THEN ('<' || SDO_RDF.replace_rdf_prefix( rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13))) || '>') WHEN substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,1)='\"' AND substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),-1,1) NOT IN ('\"','>') AND instr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),'\"\@',-1)>1 AND REGEXP_LIKE(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)), '^\"[[:print:]]*\"\@[[:alpha:]]+(-[[:alnum:]]+)*$') THEN rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)) WHEN (substr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),1,1)='\"' AND instr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),'\"^^',-1)>1 AND (length(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)))- (instr(rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13)),'\"^^',-1)+4) )>0) THEN SDO_RDF.pov_typed_literal( rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13))) ELSE SDO_RDF.raise_parse_error( 'Invalid Object', rtrim(:RDF$STC_obj,'. '||CHR(9)||CHR(10)||CHR(13))) END )" )