Wolfram Language

Build a Tango Explorer

Wikidata stores information about a great variety of subjects, including music. It provides a SPARQL endpoint to query this data.

Use SPARQL to retrieve information about tango songs to build a Dataset that can be queried.

Load GraphStore and introduce utilities for working with the Wikidata vocabulary.

Introduce various subqueries that define the relevant entities (songs listed under "tango") and the data to retrieve (composer, lyricist, audio).

Combine the query parts, marking as optional parts that might not exist (for instance, not all songs have lyrics).

A song might have multiple composers, lyricists or audio recordings, which means that the same song might appear in multiple rows with different combinations of composer, lyricist or audio. Collapse the result using an aggregate (SPARQLAggregate) in the following way: Group by "song" or "audio", which means that most of the time you get one solution per song, but if there are multiple audio examples per song, they are listed as separate results. Composers and lyricists are combined using the group_concat aggregate function, using ";" as a separator.

Compose the query with the aggregate and execute it.

Make a Dataset (and also drop the RDFString wrapperyou are not interested in the language tag).

Dataset has a rich query language. When applied to a sequence of arguments, then each argument is considered a "query operator" that is applied at the corresponding level. In the first example, you "do nothing" at the first level (All), then extract "songLabel" and "composers" at the second level.

Select rows whose "composers" contain Gardel, then show "songLabel" and "lyricists".

Find songs that have an "audio" and add a column that allows you to open the song in your browser.

Related Examples

de es fr ja ko pt-br zh