-- #1 Using Language Content-Negotiation 

SPARQL

DEFINE get:soft "soft"
SELECT ?s ?p (sql:BEST_LANGMATCH (?o, "ru, en-gb;q=0.8, en;q=0.7, *;q=0.1", "")) as ?o_filtered
FROM <http://dbpedia.org/resource/Abel_Miglietti>
WHERE {
	    ?s a foaf:Person .
		# Virtuoso Extension for setting Named Graph scope on a Remote SPARQL service
	    SERVICE <http://dbpedia.org/sparql> 
		      {
	             SELECT ?s ?p ?o 
				 FROM <http://dbpedia.org> 
				 WHERE { ?s ?p ?o .
				 		 OPTIONAL { ?p rdfs:label ?lbl } 
	             		 FILTER (?p != <http://dbpedia.org/property/abstract>)
					   }
				LIMIT 10
	          }
				  
	  }
ORDER BY ASC (COUNT (?o))  ;

-- #2 Using Language Content-Negotiation 
-- Revised using {} to group dataset modifier fragments to set scope for shared variable identifiers
-- Kills opllinux5

SPARQL

DEFINE get:soft "replace"

SELECT ?s ?p (sql:BEST_LANGMATCH (?o, "ru, en-gb;q=0.8, en;q=0.7, *;q=0.1", "")) as ?o_filtered 
FROM <http://dbpedia.org/resource/Abel_Miglietti>
WHERE {
		{
		    ?s a foaf:Person .
			# Virtuoso Extension for setting Named Graph scope on a Remote SPARQL service
		    SERVICE <http://dbpedia.org/sparql> 
			      {
	 	             SELECT ?s ?p ?o ?lbl
	 				 FROM <http://dbpedia.org> 
	 				 WHERE { ?s ?p ?o . 
                             OPTIONAL { ?p rdfs:label ?lbl } . ?p a owl:DatatypeProperty . 
	 	             		 # FILTER (?p != <http://dbpedia.org/property/abstract>)
	 					   }
					 LIMIT 10
		          }
		}
		
	  }
ORDER BY ASC (COUNT (?o))  ;


-- Github Join across Wikidata and DBpedia
-- Live Example 1


SPARQL 

DEFINE get:soft "soft"
PREFIX csv: <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv#>
PREFIX csv2: <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv> 

SELECT ?csvID ?wikiDataID ?dbpediaID

WHERE {
        { SELECT ?csvID IRI(?o) as ?wikiDataID 
		  WHERE { GRAPH csv2:			  					
			            { ?csvID csv:wikidata ?o . }
	   			 }
        }
		
        SERVICE <http://dbpedia.org/sparql> 
		       { SELECT ?wikiDataID ?dbpediaID ?p ?o2 FROM <http://dbpedia.org> 
				 WHERE { OPTIONAL { ?dbpediaID owl:sameAs ?wikiDataID; 
					                ?p ?o2
								  }
					   } 
				 LIMIT 50 
			   }
 
     } ;


-- Basic

SPARQL 

DEFINE get:soft "soft"

PREFIX csv: <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv#>
PREFIX dbp: <http://dbpedia.org/property/> 

SELECT ?w as ?WikidataID
       ?o2 as ?DBpediaID 
       xsd:string(?label) as ?Name
WHERE {
        {SELECT DISTINCT ?w WHERE {
        GRAPH <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv> 			  {?s csv:wikidata ?o . }
		
        BIND (IRI(?o) AS ?w) } }
		
        SERVICE <http://dbpedia.org/sparql> 
              { SELECT  ?w ?o2 ?label
                WHERE { GRAPH ?g { ?o2 owl:sameAs ?w. 
								   OPTIONAL {?o2 dbp:name ?label.
								  } 
						FILTER (lang(?label) = "en")} 
                       } LIMIT 500
              }
        } ;
		
-- With Positions

SPARQL


DEFINE get:soft "soft"

PREFIX csv: <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv#>
PREFIX dbp: <http://dbpedia.org/property/> 

SELECT xsd:string(?label) as ?Name
       ?w as ?WikidataID
       ?o2 as ?DBpediaID 

       
WHERE {
        {SELECT DISTINCT ?w WHERE {
        GRAPH <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv> 			  {?s csv:wikidata ?o . }
		
        BIND (IRI(?o) AS ?w) } }
		
        SERVICE <http://dbpedia.org/sparql> 
              { SELECT  ?w ?o2 ?label
                WHERE { GRAPH ?g { ?o2 owl:sameAs ?w. 
								   OPTIONAL {?o2 dbp:name ?label.
								  } 
						FILTER (lang(?label) = "en")} 
                       } LIMIT 500
              }
        } ;

-- Live Results Link: https://tinyurl.com/m4g66kl


-- With Images


SPARQL

DEFINE get:soft "soft"

PREFIX csv: <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv#>
PREFIX dbp: <http://dbpedia.org/property/> 
PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT ?o2 as ?href
       ?w as ?WikidataID
       ?o2 as ?DBpediaID 
       xsd:string(?label) as ?name
       ?position
       ?image
WHERE {
        {
		SELECT DISTINCT ?w WHERE {
        GRAPH <https://gist.githubusercontent.com/lawlesst/bdbd2142c2ab667eae1be3b7a789f5da/raw/643196cb31a13ddc3746d7a340bf3674d31f3bc2/top_250_by_pages.csv> 			  { ?s csv:wikidata ?o . }
		
        BIND (IRI(?o) AS ?w) } }
		
        SERVICE <http://dbpedia.org/sparql> 
              { SELECT  ?w ?o2 ?label ?position ?image
                WHERE { GRAPH ?g { 
									?o2 owl:sameAs ?w;
                                    foaf:depiction ?image . 
	                            	OPTIONAL {?o2 dbp:name ?label } .
                                    OPTIONAL {?o2 dbo:position ?position } .

						FILTER (lang(?label) = "en")} 
						
                       } LIMIT 500 
              }
        }
		
-- Live Results Link: https://tinyurl.com/kok7ssx