Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,031 members, 7,807,061 topics. Date: Wednesday, 24 April 2024 at 09:05 AM

Urgent Help On Sparql Query Ontology - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Urgent Help On Sparql Query Ontology (2767 Views)

His Mysql Query Returned Duplicate Output. Help Him / Php/mysql Help:how To Run Sql Query From A Link / Help Needed With Mysql/php Date Query (2) (3) (4)

(1) (2) (Reply) (Go Down)

Urgent Help On Sparql Query Ontology by mj(m): 2:52am On Jun 17, 2012
I have my ontology on diagnosis, it contains patients name, disease, some disease name are synonym to the other, i want a query that will select all the patients that have that disease ( for instance another name for brain tumor is brain neoplasm), if i select brain tumor, i want it to also bring out results for patients with brain neoplasm as well. I'm in need of this asap, thanks.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 3:05am On Jun 17, 2012
mj: I have my ontology on diagnosis, it contains patients name, disease, some disease name are synonym to the other, i want a query that will select all the patients that have that disease ( for instance another name for brain tumor is brain neoplasm), if i select brain tumor, i want it to also bring out results for patients with brain neoplasm as well. I'm in need of this asap, thanks.

Have you tried this tutorial? http://jena.sourceforge.net/ARQ/Tutorial/data.html
Re: Urgent Help On Sparql Query Ontology by mj(m): 3:31am On Jun 17, 2012
thanks for your response, this is my ontology done on protege 4.2, I defined Brain_Neoplasm using Synonyms Brain_Tumor, etc, i have been on this for a while now, i'm checking on the link you sent though. pls helpppppp, pls.
    </owl:NamedIndividual>
<?xml version="1.0"?>


<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY Diagnosis "http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#" >
]>


<rdf:RDF xmlns="http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#"
xml:base="http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:Diagnosis="http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis"/>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Datatypes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#DOB -->

<owl:ObjectProperty rdf:about="&Diagnosis;DOB"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Disease -->

<owl:ObjectProperty rdf:about="&Diagnosis;Disease">
<rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
</owl:ObjectProperty>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#DiseaseN -->

<owl:ObjectProperty rdf:about="&Diagnosis;DiseaseN"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#GroupName -->

<owl:ObjectProperty rdf:about="&Diagnosis;GroupName"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Synonyms -->

<owl:ObjectProperty rdf:about="&Diagnosis;Synonyms"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#patient -->

<owl:ObjectProperty rdf:about="&Diagnosis;patient">
<rdfs:subPropertyOf rdf:resource="&Diagnosis;patient"/>
</owl:ObjectProperty>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Caused -->

<owl:DatatypeProperty rdf:about="&Diagnosis;Caused"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#DOB -->

<owl:DatatypeProperty rdf:about="&Diagnosis;DOB"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#DiseaseName -->

<owl:DatatypeProperty rdf:about="&Diagnosis;DiseaseName">
<rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
</owl:DatatypeProperty>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Doctor -->

<owl:DatatypeProperty rdf:about="&Diagnosis;Doctor"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#FullName -->

<owl:DatatypeProperty rdf:about="&Diagnosis;FullName"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#GroupValue -->

<owl:DatatypeProperty rdf:about="&Diagnosis;GroupValue"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#sex -->

<owl:DatatypeProperty rdf:about="&Diagnosis;sex"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#url -->

<owl:DatatypeProperty rdf:about="&Diagnosis;url"/>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Disease -->

<owl:Class rdf:about="&Diagnosis;Disease"/>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Patients -->

<owl:Class rdf:about="&Diagnosis;Patients"/>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Aderenle -->

<owl:NamedIndividual rdf:about="&Diagnosis;Aderenle">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">22/04/1993</DOB>
<FullName rdf:datatype="&xsd;string">Adegboyega Aderenle</FullName>
<sex rdf:datatype="&xsd;string">Female</sex>
<Disease rdf:resource="&Diagnosis;Brain_Neoplasm"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Ayotunde -->

<owl:NamedIndividual rdf:about="&Diagnosis;Ayotunde">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<Disease rdf:resource="&Diagnosis;Pineoblastoma"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Balogun -->

<owl:NamedIndividual rdf:about="&Diagnosis;Balogun">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<FullName rdf:datatype="&xsd;string">Abdulateef Oluwagbenga</FullName>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Brain_Neoplasm -->

<owl:NamedIndividual rdf:about="&Diagnosis;Brain_Neoplasm">
<rdf:type rdf:resource="&Diagnosis;Disease"/>
<DiseaseName rdf:datatype="&xsd;string">Brain Neoplasm</DiseaseName>
<Doctor rdf:datatype="&xsd;string">Mrs Mabayoje</Doctor>
<Caused rdf:datatype="&xsd;string">Virus</Caused>
<url rdf:datatype="&xsd;string">http://www.brainneoplasm.com</url>
<patient rdf:resource="&Diagnosis;Aderenle"/>
<Synonyms rdf:resource="&Diagnosis;Brain_Tumor"/>
<owl:sameAs rdf:resource="&Diagnosis;Brain_Tumor"/>
<patient rdf:resource="&Diagnosis;Susan"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Brain_Tumor -->

<owl:NamedIndividual rdf:about="&Diagnosis;Brain_Tumor">
<rdf:type rdf:resource="&Diagnosis;Disease"/>
<Caused rdf:datatype="&xsd;string">Bacteria</Caused>
<DiseaseName rdf:datatype="&xsd;string">Brain Tumor</DiseaseName>
<Doctor rdf:datatype="&xsd;string">Mr. Amos Bajeh</Doctor>
<url rdf:datatype="&xsd;string">http://www.braintumor.com</url>
<Synonyms rdf:resource="&Diagnosis;Brain_Neoplasm"/>
<patient rdf:resource="&Diagnosis;Olaniyi"/>
<patient rdf:resource="&Diagnosis;Rashidat"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Joy -->

<owl:NamedIndividual rdf:about="&Diagnosis;Joy">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">33/22/1221</DOB>
<sex rdf:datatype="&xsd;string">Famale</sex>
<FullName rdf:datatype="&xsd;string">Ibekwe Joy</FullName>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Olaniyi -->

<owl:NamedIndividual rdf:about="&Diagnosis;Olaniyi">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">4/2/1989</DOB>
<FullName rdf:datatype="&xsd;string">Ayeni Olaniyi</FullName>
<sex rdf:datatype="&xsd;string">Male</sex>
<Disease rdf:resource="&Diagnosis;Brain_Tumor"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Omolayo -->

<owl:NamedIndividual rdf:about="&Diagnosis;Omolayo">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">12/02/2003</DOB>
<sex rdf:datatype="&xsd;string">Male</sex>
<FullName rdf:datatype="&xsd;string">Oshadami Omolayo</FullName>
<Disease rdf:resource="&Diagnosis;Brain_Tumor"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Oshadami -->

<owl:NamedIndividual rdf:about="&Diagnosis;Oshadami">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<FullName rdf:datatype="&xsd;string">Oshadami MJ</FullName>
<Disease rdf:resource="&Diagnosis;Pineoblastoma"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Pineal_Pnet -->

<owl:NamedIndividual rdf:about="&Diagnosis;Pineal_Pnet">
<rdf:type rdf:resource="&Diagnosis;Disease"/>
<Synonyms rdf:resource="&Diagnosis;Pineoblastoma"/>
<owl:sameAs rdf:resource="&Diagnosis;Pineoblastoma"/>
<Synonyms rdf:resource="&Diagnosis;Pnet_Of_Pineal_Gland"/>
<owl:sameAs rdf:resource="&Diagnosis;Pnet_Of_Pineal_Gland"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Pineoblastoma -->

<owl:NamedIndividual rdf:about="&Diagnosis;Pineoblastoma">
<rdf:type rdf:resource="&Diagnosis;Disease"/>
<Caused rdf:datatype="&xsd;string">Hunger of the brain</Caused>
<Doctor rdf:datatype="&xsd;string">Mrs Janet Oshadami</Doctor>
<url rdf:datatype="&xsd;string">pineoblastoma.com</url>
<Synonyms rdf:resource="&Diagnosis;Pineal_Pnet"/>
<owl:sameAs rdf:resource="&Diagnosis;Pnet_Of_Pineal_Gland"/>
<Synonyms rdf:resource="&Diagnosis;Pnet_Of_Pineal_Gland"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Pnet_Of_Pineal_Gland -->

<owl:NamedIndividual rdf:about="&Diagnosis;Pnet_Of_Pineal_Gland">
<rdf:type rdf:resource="&Diagnosis;Disease"/>
<Synonyms rdf:resource="&Diagnosis;Pineal_Pnet"/>
<Synonyms rdf:resource="&Diagnosis;Pineoblastoma"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Rashidat -->

<owl:NamedIndividual rdf:about="&Diagnosis;Rashidat">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">22/22/2223</DOB>
<sex rdf:datatype="&xsd;string">Female</sex>
<FullName rdf:datatype="&xsd;string">Rashidat Zubeiru</FullName>
<Disease rdf:resource="&Diagnosis;Brain_Tumor"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#Susan -->

<owl:NamedIndividual rdf:about="&Diagnosis;Susan">
<rdf:type rdf:resource="&Diagnosis;Patients"/>
<DOB rdf:datatype="&xsd;string">31/12/1993</DOB>
<sex rdf:datatype="&xsd;string">Famale</sex>
<FullName rdf:datatype="&xsd;string">Olofua Susan</FullName>
<Disease rdf:resource="&Diagnosis;Brain_Neoplasm"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#group_1 -->

<owl:NamedIndividual rdf:about="&Diagnosis;group_1">
<GroupValue rdf:datatype="&xsd;string">One</GroupValue>
<DiseaseN rdf:resource="&Diagnosis;Brain_Neoplasm"/>
<DiseaseN rdf:resource="&Diagnosis;Brain_Tumor"/>
<owl:sameAs rdf:resource="&Diagnosis;group_2"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#group_2 -->

<owl:NamedIndividual rdf:about="&Diagnosis;group_2">
<DiseaseN rdf:resource="&Diagnosis;Pineoblastoma"/>
</owl:NamedIndividual>



<!-- http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#group_3 -->

<owl:NamedIndividual rdf:about="&Diagnosis;group_3"/>
</rdf:RDF>



<!-- Generated by the OWL API (version 3.3.1957) http://owlapi.sourceforge.net -->


Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 11:17am On Jun 17, 2012
You say you have Brain_Neoplasm defined in the same manner as Brain_Tumor? Where?

Also, where is your select statement?
Re: Urgent Help On Sparql Query Ontology by mj(m): 9:31pm On Jun 17, 2012
Thanks Kobojunkie, I have modified the ontology, you will now see <Synonyms> on each disease, this is my select statement for patient with Brain_Neoplasm, but its not selecting patients with Brain Tumor, how can I make it select patients with Brain_Tumor since Brain_Tumor is synonym to Brain_Neoplasm as stated in my ontology. Thanks.
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.


}
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 5:15am On Jun 18, 2012
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {
?x table: FullName ?FullName;
table: DOB ?DOB;
table: sex ?sex;
table: Disease ?y. //Or is this really meant to be table: Disease table:y?
FILTER regex(?y, "/Brain/", "i" )
}

Why not use a Regex solution here?

I am not able to test this, but what I suggest is your try using REGEX to filter the records. Ofcourse the regex expression has to be of the xquery regex language http://www.w3.org/TR/xpath-functions/#regex-syntax
Re: Urgent Help On Sparql Query Ontology by mj(m): 7:52am On Jun 18, 2012
the filter reg is use for searching for string, and its not working, im trying to query semantically here, pls look at it again, im also wrkin on it as well. thanks
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 11:14am On Jun 18, 2012
mj: the filter reg is use for searching for string, and its not working, im trying to query semantically here, pls look at it again, im also wrkin on it as well. thanks

I don't understand what you mean that the Filter reg is used for searching for strings? Is it possible to know what the exact problem using that is? Isn't the information you are filtering of string representation? When Filtering using regex function, you pretty much need to verify the regex expression there.

And do explain what you mean by you are trying to query semantically? Cause I am under the impression that this is sparql query that you need to query your records. I am not well-versed in SPARQL.

In the meantime, Here is a Tutorial on that. http://jena.apache.org/tutorials/sparql_filters.html
Re: Urgent Help On Sparql Query Ontology by mj(m): 2:25pm On Jun 18, 2012
I really do appreciate ur response, d idea of the ontology is to be able to find records that really do not depend on the exact match of the keyword you type, for instance I might type brain_tumor, although no patient with record of brain_tumor but I'm having results since there are patients with brain_neoplasm based on d fact that I have related brain_tumor with brain_neoplasm on d ontology as synonyms...I hope this helps. Thanks.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 2:29pm On Jun 18, 2012
mj: I really do appreciate ur response, d idea of the ontology is to be able to find records that really do not depend on the exact match of the keyword you type, for instance I might type brain_tumor, although no patient with record of brain_tumor but I'm having results since there are patients with brain_neoplasm based on d fact that I have related brain_tumor with brain_neoplasm on d ontology as synonyms...I hope this helps. Thanks.

From what you have above, I think you mean you want to be able to return results for records for both Disease: brain_tumor AND Disease: brain_neoplasm? Am I correct?

If Yes, what is wrong with querying using the Filter option? Why aren't you able to do that? Or why do you not want to do that? Another possible approach is to do a UNION on the records something like RECORDS FOR Disease: brain_tumor UNION RECORDS FOR Disease: brain_neoplasm

If No, help me better understand please.
Re: Urgent Help On Sparql Query Ontology by mj(m): 2:45pm On Jun 18, 2012
yes, thats what im trying to do, but the user supplies me jst a keyword, i have to check for records on that keyword and also check for the synonyms automatically, this is the union select statement i did use for it, its not showing the results of the Synonyms (Brain_Neoplasm), is jst showing results of patients with Brain_Tumor only, if i add the synonyms to the patient record it works, but that should not be the case, i cant be adding the disease and their synonyms to each patient. I know i'm missing something.Thanks.
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {
{
?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Tumor.
}
UNION
{
?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Synonyms table:Brain_Tumor.
}
}
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 3:03pm On Jun 18, 2012
Here are some queries to test

a) see if this works
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>

SELECT ?sex ?DOB ?Brain
WHERE { table:DOB ?DOB. table:sex ?sex. table Disease:Brain_Tumor ?Brain}



b) Also test this

PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>

SELECT ?sex ?DOB ?Brain
WHERE { table: DOB ?DOB. table:sex ?sex. Disease: Brain_Neoplasm ?Brain }


c) Then test this and see if it works

PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>

SELECT ?sex ?DOB ?Brain
WHERE { { table: DOB ?DOB. table:sex ?sex. table Disease: Brain_Tumor ?Brain}
UNION { table: DOB ?DOB. table:sex ?sex. Disease: Brain_Neoplasm ?Brain } }


i) Make sure your expression is correctly specified for the columns you want pulled from the record
ii) Watch syntax


Test each of the pieces above to find out where the problem is.
Re: Urgent Help On Sparql Query Ontology by mj(m): 3:33pm On Jun 18, 2012
the code i posted is working is just that i need to add the synonyms to each patient which should not be the case, maybe im missing something in my ontology i dnt know. take Kobojunkie as a doctor, you called disease of the brain Brain_Neoplasm, another doctor calls it Brain_Tumor, you keep records in the hospital database using Brain_Neoplasm, another doctor uses Brain_Tumor, you have no idea there is another name for Brain_Neoplasm, you came to the system and type Brain_Neoplasm (Looking for patients with Brain Neoplasm) but the result is not conclusive since Brain_Neoplasm is synonym to Brain_Tumor. Using Ontology to solve this problem. the aim is for you to look for patients with Brain_Tumor but patients with Brain_Neoplasm comes up as well without you typing anything on Brain_Neoplasm ( The system checks for patients with the keyword you type and then check for its synonyms and uses the synonyms to check for patients having that synonym disease. I hope this make sense more. This project means alot to me, its my final year project, I have less than a week to submit. Thanks.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 4:17pm On Jun 18, 2012
Systems are not smart enough, without user's help, to figure out what words are synonyms and what words are not. I have never had to do work with a tag like <Synonym>, however if you understand the idea behind queries, what they do is allow YOU define the relationship between the words yourself in some way. And that is why I initially suggested you use REGEX filter. Which is infact a best solution, in my opinion, and is flexible enough for you to modify just once for all.

The second approach, is using UNIONS, essentially a JOIN on results that first query for Brain_tumor, and then those the results from the second query for Brain_Neoplasm.

The third approach is, from the information you further provided, does not seem to be right as that will only return you records that fit BOTH Brain_Tumor AND Brain_Neoplasm. What you need is an OR-ing in this case.

Please see the UNION solution provided. Run it and then tell me what went wrong when you ran it.
Re: Urgent Help On Sparql Query Ontology by mj(m): 4:38pm On Jun 18, 2012
the code is not working, i dont have anything on my ontology called Brain, I created the <Synonym> myself as an Object Property Assertion on the diseases, this code is working, except that i dnt want the user to supply me the synonym word, the query should do that.
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {
{
?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Tumor.
}
UNION
{
?y table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.
}
}
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 4:56pm On Jun 18, 2012
mj: the code is not working, i dont have anything on my ontology called Brain, I created the <Synonym> myself as an Object Property Assertion on the diseases, this code is working, except that i dnt want the user to supply me the synonym word, the query should do that.
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {
{
?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Tumor.
}
UNION
{
?y table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.
}
}


Problems I see
============

1) In the above, I do not see a <Synonym> tag anywhere so I could not tell what exactly you mean when you post that.

2) You tell me the code is not working, but you do not tell me what is wrong, and where that could be from.

3) you have ?x as varible in the first but then you switch to using y? in the second query. If you are trying to do a union, you need to make sure that you use only one variable identifier in all the queries in your union

4) Are you sure that you need to use table:Disease table: and not table:Disease:. The reason I ask is because it seems what you are doing is accessing the table in [size=13pt][b]table:[/b]Disease [b]table:[/b]Brain_Neoplasm[/size]. Please clarify.

5) I asked you to run the individual queries FIRST. Confirm that they work INDIVIDUALLY, and then you join them using the UNION keyword and run them to get the UNION recordset you need.
Re: Urgent Help On Sparql Query Ontology by mj(m): 5:15pm On Jun 18, 2012
Thanks for replying to my post: Errors:
a. Error encountered after tableDOB on line 3.
b.same as above
c.same as above
this is the code i use in selecting patients with Brain_Tumor:
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Tumor.


}
For patients with Brain_Neoplasm:
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.


}
The Union will give me both patients with Brain_Neoplasm and Brain_Tumor.
But what im saying is that the user dont need to supply Brain_Tumor after supplying Brain_Tumor, since Brain_Neoplasm as stated in the ontology is a synonym of Brain_Tumor. how can i map that out, Welldone, thanks for your time.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 5:29pm On Jun 18, 2012
mj: Thanks for replying to my post: Errors:
a. Error encountered after tableDOB on line 3.
b.same as above
c.same as above
this is the code i use in selecting patients with Brain_Tumor:
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Tumor.


}
For patients with Brain_Neoplasm:
PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.


}
The Union will give me both patients with Brain_Neoplasm and Brain_Tumor.
But what im saying is that the user dont need to supply Brain_Tumor after supplying Brain_Tumor, since Brain_Neoplasm as stated in the ontology is a synonym of Brain_Tumor. how can i map that out, Welldone, thanks for your time.

First thing first, fix this problem -- Error encountered after tableDOB on line 3. Look closely at line 3 and fix the problem. Run your code, and then come back with any other error messages you may be getting.
Re: Urgent Help On Sparql Query Ontology by mj(m): 5:39pm On Jun 18, 2012
ive ran the individual code, its not working.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 5:46pm On Jun 18, 2012
mj: ive ran the individual code, its not working.

When you tell me something is not working, you have to also tell me what exactly is not working. I cannot diagnose these things without having details to work with. Remember, I am not looking over your shoulder at your code, nor do I have any real clue what your RDF data even looks like.

Most systems display for you an error message of some kind to give you hints as to where the problem exists. All I have access to is vague info on the system I obtain from you, and I try to match it against what I get from http://www.w3.org/TR/rdf-sparql-query/
Re: Urgent Help On Sparql Query Ontology by mj(m): 6:00pm On Jun 18, 2012
Kobojunkie:

When you tell me something is not working, you have to also tell me what exactly is not working. I cannot diagnose these things without having details to work with. Remember, I am not looking over your shoulder at your code, nor do I have any real clue what your RDF data even looks like.

Most systems display for you an error message of some kind to give you hints as to where the problem exists. All I have access to is vague info on the system I obtain from you, and I try to match it against what I get from http://www.w3.org/TR/rdf-sparql-query/
. Thanks.
I Have uploaded the rdf online : http://www.oceandriveng.com/onlinediagnosis.rdf

You can run sparql query online here: http://librdf.org/query
RDF content URIs: http://www.oceandriveng.com/onlinediagnosis.rdf
Query I Ran:
PREFIX table: <http://www.oceandriveng.com/Diagnosis#>
SELECT ?FullName ?DOB ?sex
WHERE {

?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease table:Brain_Neoplasm.


}
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 6:17pm On Jun 18, 2012
I have been able to confirm the query below, at least runs

PREFIX table: <http://www.oceandriveng.com/Diagnosis#>
SELECT ?FullName ?DOB ?sex ?Disease
WHERE {
?x table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease ?Disease;
}

It returns 6 records, with disease listings which include Brain_tumor, Brain_Neosplasm and Pineoblastoma. Please confirm that this is correct.

1 Like

Re: Urgent Help On Sparql Query Ontology by mj(m): 6:23pm On Jun 18, 2012
Kobojunkie: I have been able to confirm the query below, at least runs



It returns 6 records, with disease listings which include Brain_tumor, Brain_Neosplasm and Pineoblastoma. Please confirm that this is correct.
Thanks we are almost there, what I want is when you ask for patients with Brain_Neoplasm, patients with Brain_Tumor should also come up automatically based on the synonym relationship. i know it has to do with the query or something.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 6:33pm On Jun 18, 2012
mj:
Thanks we are almost there, what I want is when you ask for patients with Brain_Neoplasm, patients with Brain_Tumor should also come up automatically based on the synonym relationship. i know it has to do with the query or something.

When you write code, you start small, make sure it works, and then you move to add more, debug and repeat.

PREFIX table: <http://www.oceandriveng.com/Diagnosis#>
SELECT ?FullName ?DOB ?sex ?Disease
WHERE {
?x
table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease ?Disease.
FILTER regex(?Disease, "Brain_Tumor", "i"wink
}

I ran this and even though it does not return any records(the regex "Brain_tumor" may need tweaking there), it seems to work fine.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 6:51pm On Jun 18, 2012
PREFIX table: <http://www.oceandriveng.com/Diagnosis#>
SELECT ?FullName ?DOB ?sex ?Disease
WHERE {
?x
table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease ?Disease.
FILTER regex(str(?Disease), "brain_tumor", "i" )
}

Please confirm that the above is correct. I am able to, using that, filter the records to display just the records that have brain_tumor specified while the one below UNIONS the records from filtering for both strings


PREFIX table: <http://www.oceandriveng.com/Diagnosis#>
SELECT ?FullName ?DOB ?sex ?Disease
WHERE { {
?x
table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease ?Disease.
FILTER regex(str(?Disease), "brain_tumor", "i" )}
UNION
{
?x
table:FullName ?FullName;
table:DOB ?DOB;
table:sex ?sex;
table:Disease ?Disease.
FILTER regex(str(?Disease), "brain_neoplasm", "i" )}
}

Confirm you are able to get these working.
Re: Urgent Help On Sparql Query Ontology by mj(m): 7:15pm On Jun 18, 2012
Thanks smiley smiley, yes its working, this project is a large project, but if i can overcome this problem then there wont be much problem for me on the entire project. Whats left? how do we map it in such a way that just supplying Brain_Neoplasm will also fetch patients with Brain_tumor based on the ontology using the synonym property. Thanks... there will be a custom front end that will accept the disease name. Im working with Jena API on Netbeans, if i define my synonyms in the code then im not using the power of ontology which is what this project is about, how can we make the sparql check for synonyms of the disease supplied.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 7:18pm On Jun 18, 2012
mj: yes its working.

Now next question, will this query be run from some custom frontEnd(Web application or WinClient app, Service etc.)? If yes, what framework/language is this in? Why I ask is instead of me continuing to read through that bloody lengthy document (http://www.w3.org/TR/rdf-sparql-query/ ) what I would like to suggest is that you have your client code handle the CONDITIONALS here. Define your synonyms in code there, and if no record is returned when a search on Brain tumors is executed,then you can force a search on Brain or Brain_neoplasm.
Re: Urgent Help On Sparql Query Ontology by mj(m): 7:28pm On Jun 18, 2012
mj: Thanks smiley smiley, yes its working, this project is a large project, but if i can overcome this problem then there wont be much problem for me on the entire project. Whats left? how do we map it in such a way that just supplying Brain_Neoplasm will also fetch patients with Brain_tumor based on the ontology using the synonym property. Thanks... there will be a custom front end that will accept the disease name. Im working with Jena API on Netbeans, if i define my synonyms in the code then im not using the power of ontology which is what this project is about, how can we make the sparql check for synonyms of the disease supplied.
This code checks for synonyms of Brain_Neoplasm, how can i link them with the patients.
PREFIX table: <http://www.oceandriveng.com/Diagnosis#>

SELECT ?DiseaseName

WHERE { ?x table:DiseaseName ?DiseaseName;
table:Synonyms table:Brain_Neoplasm.
}
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 7:31pm On Jun 18, 2012
mj:
This code checks for synonyms of Brain_Neoplasm, how can i link them with the patients.
PREFIX table: <http://www.oceandriveng.com/Diagnosis#>

SELECT ?DiseaseName

WHERE { ?x table:DiseaseName ?DiseaseName;
table:Synonyms table:Brain_Neoplasm.
}

^ the code there is incorrect

SPARQL query execution failed with errors:
-1:The namespace prefix in "table:DiseaseName" was not declared.
3:syntax error, unexpected $end
Re: Urgent Help On Sparql Query Ontology by mj(m): 7:34pm On Jun 18, 2012
Kobojunkie:

^ the code there is incorrect

SPARQL query execution failed with errors:
-1:The namespace prefix in "table:DiseaseName" was not declared.
3:syntax error, unexpected $end

Try it, Its working.
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 7:36pm On Jun 18, 2012
mj:

Try it, Its working.

I tried it as is, and that is what I got . . those error codes. What is Synonyms, and where is it defined?
Re: Urgent Help On Sparql Query Ontology by mj(m): 7:37pm On Jun 18, 2012
Kobojunkie:

I tried it as is, and that is what I got . . those error codes. What is Synonyms, and where is it defined?
Result Link:
www.oceandriveng.com/query.jpg

(1) (2) (Reply)

Integrating Interswitch On A Website / Hub For Programmers In Abuja / Programming in C++: A tutorial

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 128
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.