ex2cf6 CXML and Pivot Query Collection: Links: 1. http://uriburner.com/c/DJM6MU -- BBC 2. http://bit.ly/9r7t1f 3. http://bit.ly/b5zgsz 4. http://uriburner.com/c/DIZZ5N -- Cambridge Meetup 5. http://uriburner.com/c/DIHG2G -- Commerce Basics re. Variables: #### select ?s, ("This Is The Name") as ?name, () as ?href, ("http://related/href Related Name") as ?related, ("This Is The Description") as ?description, (/{resource-path}>) as ?image from virtrdf: where { ?s a virtrdf:QuadStorage } ### Key System Graph select * from where {?s ?p ?o} ## Setting a custom image mapping for DESCRIBE use in this case mo:image sparql prefix virtcxml: prefix mo: prefix foaf: insert data into virtcxml: { mo:image  virtcxml:aliasOf foaf:depiction . } ### Importing and Transforming 3rd party CXML data ## optionally set log mode based on import size log_enable (3,1); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.bluesware.ch/parlament/collection/Parlament.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.rome101.com/Portraits/2639d42498cebe71dffeb717df4c2ec5.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/worldleaders/worldleaders.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://logd.tw.rpi.edu/test/asean_education_statistics/1998-2008_ASEAN_Education_Statistics.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/uspresidents/uspresidents.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/WindowsPhone7Pivot.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/CXML/Flickr/pivot.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/ConnectItems.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/PASSChapters.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/TechEdAUc.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/TechEdAUSessions.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/teched.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/TechEdNZSessions.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/SummitSessions.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/24hrsOfPASSEvents.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/collections/PASSVirtualChapters.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nflplayers/2009nflplayers.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nflteams/2009nflteams.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nbaplayers/2009nbaplayers.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nbateams/2009nbateams.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009mlbplayers/2009mlbplayers.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009mlbteams/2009mlbteams.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nhlplayers/2009nhlplayers.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/2009nhlteams/2009nhlteams.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/collections/amg/Top_Movies.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/collections/amg/Top500_Actors.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/sportsillustrated/sportsillustrated.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://content.getpivot.com/Collections/kiva/kiva.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.metia.com/worldcup/wc2010-dz.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.goalface.com/worldcupteams.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://az4271.vo.msecnd.net/collection/collection-current.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.tweetpivot.com/collections/list_most-influential-in-tech_scobleizer.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.tweetpivot.com/collections/followers_kidehen.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://az7446.vo.msecnd.net/msdn-magazine/msdnmagazine.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.wssdemo.com/livepivot/collections/sharepoint/sharepoint.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://client2.mondeca.com/docs/pivot/frenchcommunes.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://az4271.vo.msecnd.net/collection/collection-current.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://pivot.lobsterpot.com.au/collections/CXML/Flickr/pivot.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://images.appletoncompassion.org/deepzoomfull/AppletonCompassionFull.cxml'); DB.DBA.CXML_TO_RDF_IMPORT_URL ('http://www.microsoft.com/bi/CustomerStoryPivot/customers.cxml'); #### ### Sanity Check 1 ### # Capture Subject URI in QR Code # Use Name as anchor Text # Use URI as href # Use Image URL for Tiles (DZI), also add QR Code (via ?qrcode synonym for ?href) SELECT DISTINCT ?href ?image ?href as ?qrcode ?page ?name ?description ?created ?modified ?country ?postcode ?region ?latitude ?longitude ?locality FROM WHERE { ?href a foaf:Person ; foaf:depiction ?image; foaf:name ?name; foaf:homepage ?page; dc:description ?description; dcterms:created ?created; dcterms:modified ?modified; vcard:Country ?country; vcard:Pcode ?postcode; vcard:Region ?region; vcard:Locality ?locality; geo:lat ?latitude; geo:long ?longitude. } LIMIT 3000 ### Sanity Check 2 ### # Capture Subject URI in QR Code # Use Name as anchor Text # Use URI as href # Use Image URL for Tiles (DZI) for DZC SELECT DISTINCT ?href ?image ?href as ?qrcode ?name WHERE { ?href a foaf:Person. optional {?href foaf:depiction ?image}. optional {?href foaf:name ?name}. filter (!isBlank(?href)) } ##Groupon ## Loose DEFINE sql:describe-mode "CBD" define input:inference "virtrdf-label" describe ?s where {?s a gr:ProductOrServicesSomeInstancesPlaceholder . ?s ?p ?o. ?o bif:contains "Groupon"} ## Timeframe scoped to expiration date DESCRIBE ?akaProd ?offer WHERE { ?akaProd a gr:ProductOrServicesSomeInstancesPlaceholder . ?akaProd ?p ?o. ?o bif:contains "Groupon" . ?offer gr:includes ?akaProd . ?offer gr:validThrough ?validT . filter (?validT > "2011-01-01T00:00:00Z"^^xsd:dateTime) } LIMIT 500 ## Two Date Ranges DESCRIBE ?akaProd ?offer WHERE { ?akaProd a gr:ProductOrServicesSomeInstancesPlaceholder . ?akaProd ?p ?o. ?o bif:contains "Groupon" . ?offer gr:includes ?akaProd . ?offer gr:validThrough ?validT . filter (?validT >= "2011-02-01T00:00:00Z"^^xsd:dateTime && ?validT <= "2011-03-31T00:00:00Z"^^xsd:dateTime ) } LIMIT 500 ##BBC Nature Crawled Data (kidehen.net) describe ?s from WHERE {?s ?p ?o} ##DBpedia Public Domain Movies ##Based on Danbri Linkbase from Archive.org ##SELECT SELECT * FROM FROM WHERE { ?s a . ?s . ?s foaf:depiction ?image. ?s rdfs:label ?label . filter(lang(?label) = "en") } LIMIT 2000 ## DESCRIBE DEFINE sql:describe-mode "CBD" describe ?s from from where {?s a . ?s . optional{?s foaf:depiction ?image}. optional {?s rdfs:label ?label} . filter(lang(?label) = "en") } limit 3000 ##BBC Music ## SELECT Query SELECT DISTINCT * FROM WHERE { ?s a mo:SoloMusicArtist; mo:image ?image; mo:musicbrainz ?musicbrainz; foaf:page ?href; foaf:made ?made; mo:wikipedia ?wikipedia; foaf:name ?name; rdfs:comment ?category; mo:biography ?bio. optional {?s mo:myspace ?myspace}. optional {?s mo:imdb ?imdb}. } LIMIT 1000 ## BBC Food & Drink Recipes ## DESCRIBE ##CBD DEFINE sql:describe-mode "CBD" describe ?s where {?s a dv:Recipe. ?s dv:photo ?image} limit 2000 ##SPO ##IRI filtering define sql:describe-mode "SPO" describe ?s where {?s a dv:Recipe . ?s dv:photo ?image . ?s dv:ingredient ?ing filter isIRI(?ing) } limit 500 ##SELECT ## Without QR Code define input:inference "virtrdf-label" select distinct ?s, ?label, ?page, ?source as ?href, ?image, ?title, ?name, ?cookTime, ?chef, ?serves, ?ingredient, ?instructions, ?tag where {?s a dv:Recipe. ?s dv:photo ?image. optional {?s dcterms:title ?title}. optional {?s dv:name ?name}. optional {?s dv:cookTime ?cookTime}. optional {?s dv:author ?chef}. optional {?s dv:yield ?serves}. optional {?s dv:ingredient ?ingredient. ?ingredient virtrdf:label ?label}. optional {?s dv:instructions ?instructions}. optional {?s dv:tag ?tag}. optional {?page foaf:topic ?s}. optional {?page owl:sameAs ?source} . } ##SELECT with QR Code define input:inference "virtrdf-label" select distinct ?s, ?label, ?source as ?href, ?image, ?s as ?qrcode, ?title, ?name, ?cookTime, ?chef, ?serves, ?instructions as ?description, ?tag where {?s a dv:Recipe. ?s dv:photo ?image. optional {?s dcterms:title ?title}. optional {?s dv:name ?name}. optional {?s dv:cookTime ?cookTime}. optional {?s dv:author ?chef}. optional {?s dv:yield ?serves}. optional {?s dv:ingredient ?ingredient. ?ingredient virtrdf:label ?label}. optional {?s dv:instructions ?instructions}. optional {?s dv:tag ?tag}. optional {?page foaf:topic ?s}. optional {?page owl:sameAs ?source} . } ##SELECT ## Problem Example select distinct ?s as ?qrcode, ?image, ?title, ?name, ?cookTime, ?chef, ?serves, ?ingredient, ?instructions, ?tag, ?href where {?s a dv:Recipe. ?s dv:photo ?image. optional {?s dcterms:title ?title}. optional {?s dv:name ?name}. optional {?s dv:cookTime ?cookTime}. optional {?s dv:author ?chef}. optional {?s dv:yield ?serves}. optional {?s dv:ingredient ?ingredient}. optional {?s dv:instructions ?instructions}. optional {?s dv:tag ?tag}. optional {?href foaf:topic ?s}. } limit 2000 ##Bibo Presentations ##DESCRIBE describe ?part where {?s a bibo:Slideshow. ?s dcterms:hasPart ?part. ?part foaf:depiction ?image} ##W3C ##SELECT SELECT DISTINCT ?WebID ?Name ?depiction as ?image ?HomePage as ?href ?HomePage as ?qrcode FROM WHERE {?WebID a foaf:Person. OPTIONAL {?WebID foaf:depiction ?depiction}. OPTIONAL {?WebID foaf:name ?Name} OPTIONAL {?WebID foaf:homepage ?HomePage} } ##DESCRIBE DESCRIBE ?WebID from where {?WebID a foaf:Person. optional {?WebID foaf:depiction ?image}. optional {?WebID foaf:name ?Name} optional {?WebID foaf:homepage ?HomePage} } ## CEO's URIBurner SELECT DISTINCT ?s1 as ?href, ?name, (bif:search_excerpt (bif:vector ('ceo'), ?o1)) as ?excerpt, ?sc, ?image, (?s1) as ?rank WHERE { { { SELECT DISTINCT * WHERE { ?s1 ?s1textp ?o1 . optional {?s1 foaf:depiction ?image} . ?o1 bif:contains '"ceo"' option (score ?sc). ?s1 a dbpedia-owl:Person. optional {?s1 rdfs:label ?name}. FILTER (lang(?o1) = "en") } ORDER BY DESC (?sc * 3e-1 + sql:rnk_scale ( (?s1))) } } } LIMIT 100 ## SPARQL-FED OpenEI PREFIX rdf: PREFIX rdfs: PREFIX swivt: PREFIX resource: PREFIX category: PREFIX property: SELECT DISTINCT ?organization ?organization as ?href ?image ?name ?page ?address ?place ?zip ?coordinates ?sector ?category FROM WHERE { service { ?organization swivt:page ?page. ?organization property:Region resource:Bay_Area. ?organization rdfs:label ?name. OPTIONAL { ?organization foaf:depiction ?image}. OPTIONAL { ?organization property:Address ?address. }. OPTIONAL { ?organization property:Zip ?zip. }. OPTIONAL { ?organization property:Coordinates ?coordinates. }. OPTIONAL { ?organization property:Place ?place. ?place rdfs:label ?placename.}. OPTIONAL { ?organization property:Sector ?sector. ?sector rdfs:label ?sectorname.}. OPTIONAL { ?organization rdf:type ?category. ?category rdfs:label ?categoryname.}. } } ##SKOS PREFIX skos: SELECT DISTINCT ?Concept as ?href ?prefLabel as ?name ?image WHERE { ?Concept ?x skos:Concept . { ?Concept skos:prefLabel ?prefLabel . ?Concept skos:exactmatch ?match. ?match foaf:depiction ?image FILTER (regex(str(?prefLabel), '^a.*', 'i'))  } } ORDER BY ?prefLabel LIMIT 50 OFFSET 0 ##US Presidents ## DESCRIBE DEFINE sql:describe-mode "SPO" define input:inference "http://dbpedia.org/resource/inference/rules/yago#" describe ?href WHERE {?href a yago:PresidentsOfTheUnitedStates } ##SELECT SELECT DISTINCT * WHERE {?href a yago:PresidentsOfTheUnitedStates; foaf:name ?name; dbpedia-owl:abstract ?description; skos:subject ?subject; dbpprop:relatedInstance ?related; dbpprop:predecessor ?predecessor; dbpprop:successor ?successor. optional {?href foaf:depiction ?image} filter (lang(?description) = "en") } ## ## SELECT DISTINCT ?s as ?href ?name ?description ?position ?image WHERE {?s a yago:AmericanBasketballPlayers; foaf:name ?name; dbpedia-owl:abstract ?description; dbpedia-owl:position ?position. optional {?s foaf:depiction ?image} filter (lang(?description) = "en") } limit 500 ##NFL Players SELECT DISTINCT * WHERE {?href a dbpedia-owl:AmericanFootballPlayer; foaf:depiction ?image; foaf:name ?name; dbpedia-owl:abstract ?description; dbpedia-owl:status ?status; dbpedia-owl:position ?position; foaf:page ?page. filter (lang(?description) = "en") } limit 500 ##NFL Players SELECT DISTINCT ?s as ?href ?image ?description ?name ?position ?status WHERE { ?s a dbpedia-owl:AmericanFootballPlayer; foaf:depiction ?image; foaf:name ?name; dbpedia-owl:abstract ?description; dbpedia-owl:status ?status; dbpedia-owl:position ?position. FILTER (lang(?description) = "en") } limit 500 ##Using dbpedia-owl:thumbnail instead of foaf:depiction for ?image SELECT DISTINCT * WHERE {?href a dbpedia-owl:AmericanFootballPlayer; dbpedia-owl:thumbnail ?image; foaf:name ?name; dbpedia-owl:abstract ?description; dbpedia-owl:status ?status; dbpedia-owl:position ?position; foaf:page ?page. filter (lang(?description) = "en") } limit 500 ## Worldcup 82 players SELECT DISTINCT * WHERE {?href a yago:FIFAWorldCup1982Players; foaf:name ?name; dbpedia-owl:abstract ?description; dbpedia-owl:position ?position; foaf:page ?page. optional {?href foaf:depiction ?image} filter (lang(?description) = "en") } limit 500 ###Meetups DEFINE sql:describe-mode "SPO" describe ?href from where {?href a foaf:Person; foaf:depiction ?image; foaf:name ?name} limit 1000 ##New York DEFINE input:inference "b3sifp" DEFINE sql:describe-mode "SPO" describe ?href from where {?href a foaf:Person; foaf:depiction ?image; foaf:name ?name} limit 1000 #define get:soft "replace" DEFINE sql:describe-mode "CBD" DESCRIBE ?s WHERE {?s a foaf:Person; foaf:depiction ?image. } limit 200 select distinct ?s ?image ?id from where {?s ?p ?o. ?s foaf:depiction ?image; foaf:name ?id .} limit 100 ### DESCRIBE ?s FROM WHERE {?s ?p ?o. ?s foaf:depiction ?image; foaf:name ?id .} LIMIT 200 ##BBC Demos ## Nature DEFINE sql:describe-mode "SPO" DESCRIBE ?s WHERE {?s a ; foaf:depiction ?image } limit 2500 ##SELECT SELECT DISTINCT ?s as ?href ?name ?kname ?image ?hname ?description WHERE {?s ?kingdom; dcterms:description ?description; rdfs:label ?name; ?habitat. OPTIONAL {?s foaf:depiction ?image.} ?kingdom rdfs:label ?kname. ?habitat rdfs:label ?hname} limit 2500 ## PREFIX wo: SELECT DISTINCT ?name ?href ?kingdom ?image ?habitat ?page ?adaptation ?prog WHERE {?href wo:kingdom ?kingdom; wo:adaptation ?adaptation; wo:livesIn ?habitat; rdfs:label ?name. OPTIONAL {?prog po:subject ?href.} OPTIONAL {?href foaf:depiction ?image.} OPTIONAL {?page foaf:primaryTopic ?href} } ## Programmes DEFINE sql:describe-mode "CBD" DESCRIBE ?s WHERE {?s a ; foaf:depiction ?image} LIMIT 100 ## Linked Open GeoSpecies ## ## Mammals PREFIX foaf: PREFIX txn: PREFIX rdf: PREFIX dbpedia_owl: select distinct ?s as ?href ?o as ?image ?aligned ?closeMatch where { ?s rdf:type txn:SpeciesConcept. ?s txn:inDBpediaClade dbpedia_owl:Mammal. ?s foaf:depiction ?o. optional {?s umbel:isAligned ?aligned}. optional {?s skos:closeMatch ?closeMatch}. } limit 200 ##DESCRIBE DEFINE sql:describe-mode "SPO" PREFIX foaf: PREFIX txn: PREFIX rdf: PREFIX dbpedia_owl: describe ?s where { ?s rdf:type txn:SpeciesConcept. ?s txn:inDBpediaClade dbpedia_owl:Mammal. ?s foaf:depiction ?o. ?s virtrdf:label ?name . } limit 2500 ## Insects ##DESCRIBE DEFINE sql:describe-mode "SPO" PREFIX foaf: PREFIX txn: PREFIX rdf: PREFIX dbpedia_owl: describe ?s where { ?s rdf:type txn:SpeciesConcept. ?s txn:inDBpediaClade dbpedia_owl:Insect. ?s foaf:depiction ?o. } limit 2500 ##SELECT PREFIX foaf: PREFIX txn: PREFIX rdf: PREFIX dbpedia_owl: select distinct ?s as ?href ?o as ?image ?aligned ?closeMatch ?name where { ?s rdf:type txn:SpeciesConcept. ?s txn:inDBpediaClade dbpedia_owl:Insect. ?s foaf:depiction ?o. optional {?s umbel:isAligned ?aligned}. optional {?s skos:closeMatch ?closeMatch}. optional {?aligned rdfs:label ?name}. } limit 500 ## DESCRIBE define input:inference "virtrdf-label" prefix geosp: select distinct * where {?href a ; foaf:depiction ?image ; virtrdf:label ?name ; foaf:isPrimaryTopicOf ?href ; rdfs:seeAlso ?related ; geosp:hasClassName ?className . } limit 100 DEFINE input:inference "virtrdf-label" SELECT DISTINCT * WHERE {?s a ; foaf:depiction ?image; virtrdf:label ?name; dcterms:description ?description. ?href foaf:primaryTopic ?s} DEFINE input:inference "virtrdf-label" SELECT DISTINCT * WHERE {?s a ; foaf:depiction ?image; virtrdf:label ?name; dcterms:description ?description. ?href foaf:primaryTopic ?s}