buda-base / public-digital-library

http://library.bdrc.io
4 stars 6 forks source link

display wikipedia abstracts #502

Open eroux opened 3 years ago

eroux commented 3 years ago

This can be done for entities for which we have the link to Wikidata through WikipediaJS. Here's how it could work:

run the DBPedia SPARQL endpoint with the query:

construct {
?s rdfs:comment ?desc ;
     foaf:isPrimaryTopicOf ?wikipage .
} where {
   ?s owl:sameAs <http://www.wikidata.org/entity/Q1708503> ;
        rdfs:comment ?desc ;
        foaf:isPrimaryTopicOf ?wikipage .
        FILTER(lang(?desc) = "bo" || lang(?desc) = "en" || lang(?desc) = "zh")
} LIMIT 100

get the json (can be through a direct link) :

{
  "http://dbpedia.org/resource/Longchenpa" : { "http://www.w3.org/2000/01/rdf-schema#comment" : [ { "type" : "literal", "value" : "Longchen Rabjampa, Drim\u00E9 \u00D6zer (Wylie: klong chen rab 'byams pa dri med 'od zer), commonly abbreviated to Longchenpa (1308\u20131364), known of as the \" all-knowing\", was perhaps the most famous of the realized scholars in the Nyingma school of Tibetan Buddhism. Along with Sakya Pandita and Je Tsongkhapa, he is commonly recognized as one of the three main manifestations of Manjushri to have taught in Central Tibet. His monumental work of Tibetan literature is the Seven Treasuries, while his more than 250 treatises encapsulate the core of the previous 600 years of monastic Nyingma doctrine and Buddhist thought in Tibet. Longchenpa was a critical link in the exoteric and esoteric transmission of the Dzogchen teachings. He was abbot of Samye, one of Tibet's most important monasteries and the first " , "lang" : "en" } ,
      { "type" : "literal", "value" : "\u9F8D\u6B3D\u5DF4\u5C0A\u8005\uFF08\u85CF\u8BED\uFF1A\u0F40\u0FB3\u0F7C\u0F44\u0F0B\u0F46\u0F7A\u0F53\u0F0B\u0F62\u0F56\u0F0B\u0F60\u0F56\u0FB1\u0F58\u0F66\u0F0B\u0F54\uFF0C\u85CF\u8BED\u62FC\u97F3\uFF1ALongq\u00EAn Rabjamba\uFF0C\u5A01\u5229\uFF1Aklong chen rab 'byams pa\uFF0CTHL\uFF1ALongchen Rapchampa\uFF1B1308\u5E74\uFF0D1364\u5E74\uFF09\u85CF\u50B3\u4F5B\u6559\u5BE7\u746A\u6D3E\uFF08\u7D05\u6D3E\uFF09\u7684\u4E00\u4F4D\u5B78\u8005\u8207\u4F0F\u85CF\u5E2B\uFF0C\u88AB\u8996\u84EE\u82B1\u751F\u5927\u58EB\u4E4B\u5F8C\u7684\u7B2C\u4E8C\u4F5B\u9640\u3002" , "lang" : "zh" } ] ,
    "http://xmlns.com/foaf/0.1/isPrimaryTopicOf" : [ { "type" : "uri", "value" : "http://en.wikipedia.org/wiki/Longchenpa" } ] }
}

use it to display the summary with the link to wikidata, filtering on the language of the user. This could look a bit like the block on the right of:

Capture d’écran de 2021-06-11 17-42-09

(note that the dbpedia sparql could be augmented to also get more info such as the images, it's not really difficult)

eroux commented 3 years ago

(on second thoughts, this could also be done weekly in a script, with the data being imported in Fuseki)