Sparql Properties Filter

How do I figure out what an ontological property relationship is so that I know how to properly handle a sparql query?

For example, if I want baseball league teams to win the world series.

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/resource/> 
PREFIX owl: <http://dbpedia.org/ontology/> 
PREFIX db: <http://dbpedia.org/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#broader/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX purl: <http://purl.org/dc/terms/>
PREFIX ps: <http://purl.org/dc/terms/subject/>


select  distinct *  
where { 
  ?team rdf:type owl:BaseballTeam .
  { ?team rdf:type yago:MajorLeagueBaseballTeams . }
  #{ ?team dbprop:champion dbpedia:Major_League_Baseball }
}

      

If I uncomment the last line in the request, I don't get any results. Looking at: http://dbpedia.org/page/Boston_Red_Sox

I see:

is dbpprop:champion of  dbpedia:American_League

      

I'm not sure how I would structure the syntax to filter only those teams that won the World Series (Champion) and I'm really confused about how to find out what the actual request prefixes should be.

+3


source to share


1 answer


   is dbpprop:champion of  dbpedia:American_League 

      

This offer means that American_leage has a category champion who announces the teams that have won the league.

Is-Of just tells you what properties the resource you are looking at is like a range. If you go to the domain, you will see that it has a property pointing to the original resource. Just take a look at dbpedia resource for American_league .



So, you must structure your query in such a way that you get the desired result. (You almost had it, it's just the opposite)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia: <http://dbpedia.org/resource/>  
PREFIX owl: <http://dbpedia.org/ontology/> 
PREFIX db: <http://dbpedia.org/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#broader/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX purl: <http://purl.org/dc/terms/>
PREFIX ps: <http://purl.org/dc/terms/subject/>


select distinct *  
where { 
  ?team rdf:type owl:BaseballTeam .
  ?team rdf:type yago:MajorLeagueBaseballTeams .
  // Like the one below
  dbpedia:Major_League_Baseball dbprop:champion ?team
}

      

+6


source







All Articles