This discussion is archived
4 Replies Latest reply: Dec 4, 2012 4:47 PM by user571093 RSS

no rows sleteced with SEM_RELATED function

user571093 Newbie
Currently Being Moderated
hi,

i am excersing the sem_related function sample code in oracle sem tech devloper's guide 11g.2;but got an issue i don't know what's going on in my code. the query is:

SELECT diagnosis FROM patients
WHERE SEM_RELATED(diagnosis,
'rdfs:subClassOf', '<http://www.example.org/cancer/Immune_System_Disorder>', sem_models('cancer'), sem_rulebases('OWLPRIME'))= 1;

but returned no rows for it. i created the table, the rdf table, sem_model, and entailment and inserted a couple of rows. the codes are follows:

create table patients (id number, diagnosis varchar2 (40)) TABLESPACE rdf_tblspace;
insert into patients values(1234, 'Rheumatoid_Arthritis');
insert into patients values(2345, 'Immunodeficiency_Syndrome');
insert into patients values(3456, 'AIDS');
CREATE TABLE CANCER_RDF_DATA (ID NUMBER, TRIPLE SDO_RDF_TRIPLE_S) TABLESPACE rdf_tblspace;
EXEC SEM_APIS.CREATE_SEM_MODEL('cancer', 'CANCER_RDF_DATA', 'TRIPLE');
exec sem_apis.create_entailment('cancer_idx',sem_models('cancer'),sem_rulebases('owlprime')); (sometimes with 'SEM_APIS.REACH_CLOSURE,null,null')

INSERT INTO cancer_rdf_data VALUES (1, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Immune_System_Disorder', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (2, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Autoimmune_Disease', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (3, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Rheumatoid_Arthritis', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (4, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Immunodeficiency_Syndrome', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (5, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/T_Cell_Immunodeficiency', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (6, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/AIDS', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'http://www.w3.org/2000/01/rdf-schema#Class'));
INSERT INTO cancer_rdf_data VALUES (7, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Autoimmune_Disease', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.example.org/cancer/Immune_System_Disorder'));
INSERT INTO cancer_rdf_data VALUES (8, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Rheumatoid_Arthritis', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.example.org/cancer/Autoimmune_Disease'));
INSERT INTO cancer_rdf_data VALUES (9, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/Immunodeficiency_Syndrome', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.example.org/cancer/Immune_System_Disorder'));
INSERT INTO cancer_rdf_data VALUES (10, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/T_Cell_Immunodeficiency', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.example.org/cancer/Immunodeficiency_Syndrome'));
INSERT INTO cancer_rdf_data VALUES (11, sdo_rdf_triple_s('cancer', 'http://www.example.org/cancer/AIDS', 'http://www.w3.org/2000/01/rdf-schema#subClassOf', 'http://www.example.org/cancer/T_Cell_Immunodeficiency'));

However the query above doesn't give me the expected results like in the tutorial. can anybody tell me what i am missing here. thanks in advance.

kind regards,
hong
  • 1. Re: no rows sleteced with SEM_RELATED function
    alwu Pro
    Currently Being Moderated
    Hi,

    The reason is that your table did not use URIs. However, you can try something like the following to construct URI on the fly:

    SELECT diagnosis FROM patients
    WHERE SEM_RELATED('<http://www.example.org/cancer/'||diagnosis||'>',
    'rdfs:subClassOf', '<http://www.example.org/cancer/Immune_System_Disorder>', sem_models('cancer'), sem_rulebases('OWLPRIME'))= 1;

    Let me know if it helps.

    Zhe Wu
  • 2. Re: no rows sleteced with SEM_RELATED function
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    yes it works. thanks. however the following question is how can i perform the ontology assisted query using sem_related function without constructing the uri for the table column on the fly. do i need to create a semantic index that uses a URI prefix on that table column? i tried it once and it didn't work. or there is another way to do it? thanks in advance.

    kind regards
    hong
  • 3. Re: no rows sleteced with SEM_RELATED function
    alwu Pro
    Currently Being Moderated
    Hi,

    Well, in your table, instead of using

    insert into patients values(1234, 'Rheumatoid_Arthritis');

    you can use something like

    insert into patients values(1234, '<http://www.example.org/cancer/Rheumatoid_Arthritis>');

    Alternatively, you can virtual column. For example,

    alter table patients add (diag_uri as ('<http://www.example.org/cancer/'||diagnosis||'>'));

    SELECT diagnosis FROM patients
    WHERE SEM_RELATED(diag_uri,
    'rdfs:subClassOf', '<http://www.example.org/cancer/Immune_System_Disorder>', sem_models('cancer'), sem_rulebases('OWLPRIME'))= 1;

    Thanks,

    Zhe Wu
  • 4. Re: no rows sleteced with SEM_RELATED function
    user571093 Newbie
    Currently Being Moderated
    hi zhe,

    thanks for your quick reply. however adding uri to the existing databases will change the existing table structure and might affect the normal sql query. mayby it is a better way to construct the uri on the fly. another issure for sem_related function. the syntax of sem_related described in the guide is
    SEM_RELATED(
    sub VARCHAR2,
    predExpr VARCHAR2,
    obj VARCHAR2,
    ontologyName SEM_MODELS,
    ruleBases SEM_RULEBASES,
    index_status VARCHAR2,
    lower_bound INTEGER,
    upper_bound INTEGER ) RETURN INTEGER;

    i think it maybe missed the last parameter that is used for the primary invocation corresponding to sem_distance ancillary operator. so the complete one should be like this:
    SEM_RELATED(
    ...
    upper_bound INTEGER,
    the primary invocation) RETURN INTEGER;

    thanks.

    hong

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points