Using regular expressions to manipulate data in a SPARQL query
A pure, standards-compliant SPARQL query.
A pure, standards-compliant SPARQL query.
Querying for labels and more.
I’ve understood SPARQL’s property path features well enough to demo them in the “Searching Further in the Data” section of my book Learning SPARQL. (See example files ex074 - ex085.) To be honest, I have very rarely used them in actual queries that I’ve written. I’ve only just realized how the property path slash operator can help with a pattern that I have used in a large percentage of my queries. It makes these queries more concise and removes at least one…
The easy way and the hard way.
Several years ago in the blog post RDF* and SPARQL* I described how I had played with implementations of the new reification syntax that Olaf Hartig and Bryan Thompson proposed in their paper Foundations of an Alternative Approach to Reification in RDF. I found the new syntax to be straightforward and useful. As you can see from the recent W3C Community Group Report RDF-star and SPARQL-star, this syntax has progressed—with a more search-engine-friendly spelling of the spec’s name—closer to…
The normal way and the wikibase:label service way
In my last blog entry I discussed various ways that different RDF datasets assign human-readable labels to resources, with the rdfs:label
property being at the center of them all. I mentioned how schema.org doesn’t use rdfs:label
but its own equivalent of that, schema:name
, which its schema declares as a subproperty of rdfs:label
. Since I wrote that, Fan Li pointed out that Facebook’s Open Graph protocol also has their own equivalent: og:title
, which you can see used in the HTML…
Sometimes simple, sometimes not.
First, reviewing some basics before I discuss the edge cases: resources in RDF are represented by URIs, and the spelling of a given URI often provides no clues about what the URI represents. For example, you wouldn’t know from looking at http://www.wikidata.org/entity/Q144
that it represents “dog” as a Wikipedia topic. (We’ll see below that this is a for a good reason.)
Brief but symphonic.
During the first pandemic summer I asked my wife for a cheap tenor banjo for my birthday. These are tuned like a viola and smaller than the traditional five-string banjos used for bluegrass. Instead of fingerpicking patterns with the right hand like bluegrass banjos are famous for, tenor banjo players strum chords with a pick for volume as a rhythm instrument. When you hear a banjo in old-timey jazz, that’s a tenor. (Around the time the ground was being laid for bebop, Charlie Christian…
Add, subtract, and ADJUST() dates and times.
SPARQL 1.1 has been with us for about ten years. Work on SPARQL 1.2 is currently underway, and one nice set of improvements will let us do much more with date and time values.
A VALUES-based approach.
I’ve had a decent understand of what the VALUES
keyword can do for a while (see SPARQL 1.1’s new VALUES keyword and “Creating Tables of Values in your Queries” in my book Learning SPARQL) but lately I’ve gained a greater appreciation of ways to use it. For example, last month I used it to map codes assigned by an entity recognition tool to schema.org classes. This month I found a nice way to use it to control one of Wikidata’s many cool data visualization…