Another SPARQL solution

Bravo! A solution to the latest SPARQL puzzle.

@glenn_mcdonald found a way of getting the non-Roman-god solar system bodies:

PREFIX rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wn:    <http://www.w3.org/2006/03/wn/wn20/schema/>
PREFIX id:    <http://wordnet.rkbexplorer.com/id/>

SELECT DISTINCT ?planet WHERE {
  ?s1 wn:memberMeronymOf id:synset-solar_system-noun-1 .
  ?s1 rdfs:label ?planet .
  OPTIONAL {
    ?s1 wn:containsWordSense ?ws1 .
    ?ws1 wn:word ?w .
    ?ws2 wn:word ?w .
    ?s2 wn:containsWordSense ?ws2 .
    ?s2 wn:hyponymOf id:synset-Roman_deity-noun-1 .
  }
  FILTER (!bound(?s2))
}

Isolating just the planets looks to be out of reach using the WordNet endpoint alone, but I guess that can be left as a challenge for federated query e.g. CONSTRUCTs from different datasets into a local store before SELECTing.

Update

From RobVesse -

Here's an even simpler query for yesterdays puzzle - still doesn't isolate real planets though

PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wn:  <http://www.w3.org/2006/03/wn/wn20/schema/>

SELECT DISTINCT ?label WHERE 
{
 ?s1 wn:memberMeronymOf <http://wordnet.rkbexplorer.com/id/synset-solar_system-noun-1> .
 ?s1 rdfs:label ?label.
 OPTIONAL
 {
  ?s2 wn:hyponymOf <http://wordnet.rkbexplorer.com/id/synset-Roman_deity-noun-1> .
  ?s2 rdfs:label ?label.
 }
 FILTER (!BOUND(?s2))
}

...plus...

Here's a soln using wordnet and dbpedia to show only planets not named after roman gods, requires a SPARQL 1.1 engine to run

PREFIX rdfs:    <http://www.w3.org/2000/01/rdf-schema#>
PREFIX wn:  <http://www.w3.org/2006/03/wn/wn20/schema/>

SELECT DISTINCT ?label WHERE 
{
 SERVICE <http://wordnet.rkbexplorer.com/sparql/>
 {
   ?s1 wn:memberMeronymOf <http://wordnet.rkbexplorer.com/id/synset-solar_system-noun-1> .
   ?s1 rdfs:label ?label.
 }
 MINUS
 {
  SERVICE <http://wordnet.rkbexplorer.com/sparql/>
  {
    ?s2 wn:hyponymOf <http://wordnet.rkbexplorer.com/id/synset-Roman_deity-noun-1> .
    ?s2 rdfs:label ?label.
  }
 }
 BIND(URI(CONCAT("http://dbpedia.org/resource/", ?label)) AS ?dbpResource)

Here's a suitable engine: Leviathan (a demo of the SPARQL Engine used in dotNetRDF).


danja
2011-04-12T20:19:30+01:00
sparql puzzle rdf
Related
Comments
Edit

Another SPARQL puzzle

Using the WordNet endpoint at http://wordnet.rkbexplorer.com/sparql/ I can get the names of the solar system bodies that are named after Roman gods with :

PREFIX rdfs:		<http://www.w3.org/2000/01/rdf-schema#>
PREFIX wn:	<http://www.w3.org/2006/03/wn/wn20/schema/>

SELECT DISTINCT ?label WHERE {
?s1 wn:memberMeronymOf <http://wordnet.rkbexplorer.com/id/synset-solar_system-noun-1> .
?s1 rdfs:label ?label.
?s2 wn:hyponymOf <http://wordnet.rkbexplorer.com/id/synset-Roman_deity-noun-1> .
?s2 rdfs:label ?label.
}

The challenge is to get the names of the solar system bodies that aren't named after Roman gods. (Ideally I'd like planets in the solar system... rather than ...bodies, but I can't see a suitable class).


danja
2011-04-11T20:42:00+01:00
sparql puzzle rdf
Related
Comments
Edit

Long multiplication

Querying http://dbpedia.org/sparql


PREFIX yagoc:		<http://dbpedia.org/class/yago/>
SELECT COUNT(?set1) where {
?set1 a yagoc:ProgrammingLanguage106898352 .
}

result = 336

PREFIX dbpp:		<http://dbpedia.org/property/>

SELECT COUNT(?set2) where {
?set2 dbpp:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_programming_language>
}

result = 426

disjunction, language is in set1 OR set2

PREFIX dbpp:		<http://dbpedia.org/property/>
PREFIX yagoc: <http://dbpedia.org/class/yago/>
SELECT count(?s) where {
{
?s dbpp:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_programming_language> .
} UNION {
?s a yagoc:ProgrammingLanguage106898352 .
}
}

result = 762

conjunction, language is in set1 AND set2

PREFIX dbpp:		<http://dbpedia.org/property/>
PREFIX yagoc: <http://dbpedia.org/class/yago/>
SELECT COUNT(?set) where {
?set a yagoc:ProgrammingLanguage106898352 .
?set dbpp:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_programming_language> .
}

result = 178

PREFIX dbpp:		<http://dbpedia.org/property/>
PREFIX yagoc: <http://dbpedia.org/class/yago/>

SELECT count(?and) where {
{
?or dbpp:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_programming_language> .
} UNION {
?or a yagoc:ProgrammingLanguage106898352 .
}
?and dbpp:wikiPageUsesTemplate <http://dbpedia.org/resource/Template:Infobox_programming_language> .
?and a yagoc:ProgrammingLanguage106898352 .

FILTER(?and = ?or)
}

result = 356!?

Took me a long while to realise what that number represents, definitely time for a break...

What I'm trying to find (if it's possible) are queries to look at the difference between the sets above, the 762 - 178 = 584 part. I'm hoping something along the lines of Finding Resources that don't have a certain property might work. If anyone knows an idiom that'll work (or knows that it isn't possible) please ping me.


danja
2011-03-28T13:59:45+01:00
sparql puzzle rdf
Related
Comments
Edit