Search code examples
sparqlwikidatawikidata-query-service

SPARQL query that returns Wikidpedia labels from Wikidata itemLabel


I am new to SPARQL, Is it possible to write a query that returns Wikipedia box information for a corresponding item label from the Wikipedia box for the Arabic Language that appears at the bottom of the Wikidata item page?

see the picture:

Wikipedia box

Instead of the Wikipedia URL in the following Query, I need to return the Wikipedia Label, in our case (الرامة (جنين))

Try Query on Wikidata Query Service

SELECT DISTINCT ?article ?item ?itemLabel ?itemDescription ?entity_type ?main_category (GROUP_CONCAT(DISTINCT(?altLabel); separator = ", ") AS ?altLabel_list) WHERE {
                            ?item ?label "الرامة"@ar.
                            ?item wdt:P31 ?entity_type .
                            MINUS { ?item wdt:P31 wd:Q4167410}
                            OPTIONAL{    ?item wdt:P910 ?main_category}
                            ?article schema:about ?item;
                            schema:isPartOf <https://ar.wikipedia.org/>;
                            OPTIONAL { ?item skos:altLabel ?altLabel . FILTER (lang(?altLabel) = "ar") }
                            SERVICE wikibase:label { bd:serviceParam wikibase:language "ar" .} 
                        
                                                        }
                            GROUP BY ?article ?item ?itemLabel ?itemDescription ?entity_type ?main_category

Solution

  • This is the answer by the UninformedUser

    >      SELECT ?article ?wikipediaLabel WHERE 
    >         {           ?article schema:about wd:Q12187640 .     ?article schema:isPartOf <https://ar.wikipedia.org/>; schema:name
    > ?wikipediaLabel  }