Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,199,136 members, 7,970,493 topics. Date: Wednesday, 09 October 2024 at 10:06 AM |
Nairaland Forum / Science/Technology / Programming / Urgent Help On Sparql Query Ontology (2815 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)
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> |
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#> b) Also test this PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#> c) Then test this and see if it works PREFIX table: <http://www.semanticweb.org/denrele/ontologies/2012/5/Diagnosis#> 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#> |
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. 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: 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:. 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#> 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 runsThanks 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: 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#> 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#> 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
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 , 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 , 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: ^ 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: Try it, Its working. |
Re: Urgent Help On Sparql Query Ontology by Kobojunkie: 7:36pm On Jun 18, 2012 |
mj: 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:Result Link: www.oceandriveng.com/query.jpg |
Suitable Processor For Programming / New Glo Unlimited Data Cheat / Challenges Finding A Technical Co-founder In Nigeria
(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. 123 |