{
"$type": "site.standard.document",
"content": {
"$type": "site.standard.content.markdown",
"text": "I've never enjoyed SPARQL syntax and found it confussing coming from SQL. That has made me not use or explore Wikidata as much as I wanted.\n\nThis, however, seems to have changed after being able to use ChatGPT to generate the queries for me. Or at least to guide me through the process. It's an amazing way to explore Wikidata without having to learn SPARQL syntax!\n\nI wanted to get some data about asteroids and I was able to do it with the following query... to ChatGPT! Definitely not as [accurate or detailed as an official source could be](https://ssd.jpl.nasa.gov/tools/sbdb_query.html#!#results), but useful to quickly check some facts.\n\n\n\nAfter some small tweaks, I got [to the following query](https://w.wiki/6bdo):\n\n```sparql\nSELECT\n ?asteroidLabel\n ?discovered\n ?discovererLabel\nWHERE {\n ?asteroid wdt:P31 wd:Q3863; # Retrieve instances of \"asteroid\"\n wdt:P61 ?discoverer; # Retrieve discoverer of the asteroid\n wdt:P575 ?discovered; # Retrieve discovered date of the asteroid\n SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }\n}\nORDER BY DESC(?discovered)\n```\n\nThe most interesting thing is that while crafting the query, I was able to learn different things that I haven't even noticed in the past as I was mostly copy pasting queries form the examples.\n\nFor example, I didn't know that you can use `SERVICE wikibase:label` to get the labels of the entities.\n\nThis opens a whole new world of datasets and I'm looking forward to exploring more of them!",
"version": "1.0"
},
"description": "I've never enjoyed SPARQL syntax and found it confussing coming from SQL. That has made me not use or explore Wikidata as much as I wanted. This, however, seems to have changed after being able to use ChatGPT to generate the queries for me. Or at least to guide me through the...",
"path": "/wikidata-sparql-chatgpt",
"publishedAt": "2023-04-18T00:00:00.000Z",
"site": "at://did:plc:4z5i7njrld66ew36htufcwry/site.standard.publication/3mo43d2tmt2ov",
"textContent": "I've never enjoyed SPARQL syntax and found it confussing coming from SQL. That has made me not use or explore Wikidata as much as I wanted.\n\nThis, however, seems to have changed after being able to use ChatGPT to generate the queries for me. Or at least to guide me through the process. It's an amazing way to explore Wikidata without having to learn SPARQL syntax!\n\nI wanted to get some data about asteroids and I was able to do it with the following query... to ChatGPT! Definitely not as accurate or detailed as an official source could be, but useful to quickly check some facts.\n\nAfter some small tweaks, I got to the following query:\n\nThe most interesting thing is that while crafting the query, I was able to learn different things that I haven't even noticed in the past as I was mostly copy pasting queries form the examples.\n\nFor example, I didn't know that you can use SERVICE wikibase:label to get the labels of the entities.\n\nThis opens a whole new world of datasets and I'm looking forward to exploring more of them!",
"title": "Wikidata with SPARQL and ChatGPT"
}