Reputation: 45
I'm very new to SparQL and am currently really struggling to get the correct results to show, I have experimented with this for the last 3 days and at the end of an extensive Google search I felt it was time to ask for help.
The issue that I'm having is that the query results are displaying, however I only want to display the university names with the module "Semantic Web", however even with the current FILTER the results show for all three of the universities and only two of them "University of Kent and Manchester" have that specific module. I was hoping someone would be able to led me in the right direction as i don't believe that the Canterbury christ church uni should even be shown, let alone showing it has that module.
My current attempted code:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX a: <https://dl.dropboxusercontent.com/u/270116418/schema.rdf>
SELECT DISTINCT ?University ?Modules
WHERE {
?u rdf:type a:University. ?c rdf:type a:Courses. ?m rdf:type a:Modules.
?u a:uniName ?University. ?c a:coursesName ?Courses. ?m a:moduleName ?Modules .
FILTER regex( ?Modules, "Semantic")
}
A direct link is below :
http://librdf.org/query?uri=http%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F270116418%2FAssignment_1.rdf+http%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F270116418%2FAssignment_1_2.rdf+http%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F270116418%2FAssignment_1_3.rdf&query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E+%0D%0A%0D%0APREFIX+a%3A+%3Chttps%3A%2F%2Fdl.dropboxusercontent.com%2Fu%2F270116418%2Fschema.rdf%3E%0D%0A%0D%0A%0D%0ASELECT+DISTINCT+%3FUniversity+%3FModules%0D%0AWHERE+{%0D%0A%3Fu+rdf%3Atype+a%3AUniversity.+%3Fc+rdf%3Atype+a%3ACourses.+%3Fm+rdf%3Atype+a%3AModules.%0D%0A%3Fu+a%3AuniName+%3FUniversity.+%3Fc+a%3AcoursesName+%3FCourses.+%3Fm+a%3AmoduleName+%3FModules+.+FILTER+regex%28+%3FModules%2C+%22Semantic%22%29%0D%0A}%0D%0AORDER+BY+%3FUniversity&language=sparql&Run+Query=Run+Query&.cgifields=json&.cgifields=raw
Thank you in advance,
Chris.H
Upvotes: 0
Views: 111
Reputation: 16630
You have a pattern with disconnected parts.
Tracing back from ?Modules, you only get to ?m.
?u rdf:type a:University.
?c rdf:type a:Courses.
?u a:uniName ?University.
if that has multiple matches on (?u, ?c) then it will multiple up the matches of ?m and ?module resulting in duplicates.
Execute your query with SELECT *
to see the full details.
Upvotes: 2