HowTo -- CHAT-GPT and DBpedia SPARQL Query Generation from Natural Language Prompts

Richer Template and SPARQL-FED via URIBurner

Template:

dbo:TelevisionShow;dbo:TelevisionShow;;does <A> have more episodes than <B>?;ask where { <A> dbo:numberOfEpisodes ?a . <B> dbo:numberOfEpisodes ?b . filter (?a > ?b) };select distinct ?a, ?b where {  ?a dbo:numberOfEpisodes ?x . ?b dbo:numberOfEpisodes ?y };
dbo:TelevisionShow;;;does the new <A> series have more episodes than the old one?;ask where { <A> rdfs:label ?l . ?a rdf:type dbo:TelevisionShow . ?a foaf:name ?l . ?a dbo:completionDate ?ad . ?a dbo:numberOfEpisodes ?an . ?b rdf:type dbo:TelevisionShow . ?b foaf:name ?l . ?b dbo:completionDate ?bd . ?b dbo:numberOfEpisodes ?bn . filter(?ad > ?bd && ?an > ?bn) };select distinct ?a where {  ?a rdfs:label ?l . ?x rdf:type dbo:TelevisionShow . ?x foaf:name ?l . ?x dbo:completionDate ?ad . ?x dbo:numberOfEpisodes ?an . ?y rdf:type dbo:TelevisionShow . ?y foaf:name ?l . ?y dbo:completionDate ?bd . ?y dbo:numberOfEpisodes ?bn . };
dbo:MusicalArtist;dbo:MusicalWork;;for which label did <A> record his first <B>?;select ?a where { ?b rdf:type <B> . ?b dbo:artist <A> . ?b dbo:releaseDate ?c . ?b dbo:recordLabel ?a } order by ?c offset 0 limit 1;select distinct ?a, ?b where {  ?y rdf:type ?b . ?y dbo:artist ?a . ?y dbo:releaseDate ?c . ?y dbo:recordLabel ?x  };
dbo:MusicalArtist;dbo:MusicalWork;;for which label did <A> record his second <B>?;select ?a where { ?b rdf:type <B> . ?b dbo:artist <A> . ?b dbo:releaseDate ?c . ?b dbo:recordLabel ?a } order by ?c offset 1 limit 1;select distinct ?a, ?b where {  ?y rdf:type ?b . ?y dbo:artist ?a . ?y dbo:releaseDate ?c . ?y dbo:recordLabel ?x  };
dbo:Country;dbo:MusicGenre;;give me all <A> <B> record labels.;select distinct ?uri where { ?uri rdf:type dbo:RecordLabel . ?uri dbo:genre <B>. ?uri dbo:country <A>. };select distinct ?a, ?b where {  ?uri rdf:type dbo:RecordLabel . ?uri dbo:genre ?b. ?uri dbo:country ?a.  };
;;;give me all actors;select ?a where { [] dbo:starring ?a };select distinct  where {  [] dbo:starring ?x  };
dbo:Film;;;give me all actors starring in <A>;select ?a where { <A> dbo:starring ?a };select distinct ?a where {  ?a dbo:starring ?x  };
<http://dbpedia.org/class/yago/FilmDirector110088200>;;;give me all actors starring in movies directed by <A>;select distinct ?uri where { ?uri dbo:starring ?x . ?uri dbo:director <A> };select distinct ?a where { ?uri dbo:starring ?x . ?uri dbo:director ?a };
dbo:Writer;;;give me all books by <A> with more than 300 pages.;select distinct ?uri where { ?uri rdf:type dbo:Book . ?uri dbo:author <A> . ?uri dbo:numberOfPages ?x . filter (?x > 300) };select distinct ?a where {  ?uri rdf:type dbo:Book . ?uri dbo:author ?a . };
dbo:Band;;;give me all members of <A>;select distinct ?uri where { <A> dbo:bandMember ?uri . };select distinct ?a where {  ?a dbo:bandMember ?uri .  };
<http://dbpedia.org/class/yago/FilmDirector110088200>;;;give me all movies directed by <A>;select distinct ?uri where { ?uri rdf:type dbo:Film . ?uri dbo:director <A> };select distinct ?a where {  ?uri rdf:type dbo:Film . ?uri dbo:director ?a  };
dbo:TelevisionShow;;;give me the new <A> series;describe ?a where { <A> rdfs:label ?l . ?a a dbo:TelevisionShow . ?a foaf:name ?l . ?a dbo:completionDate ?ad } order by desc(?ad) limit 1;select distinct ?a where {  ?a rdfs:label ?l . ?x a dbo:TelevisionShow . ?x foaf:name ?l . ?x dbo:completionDate ?ad  };
dbo:Book;;;how many pages does <A> have?;select distinct ?n where { <A> dbo:numberOfPages ?n . };select distinct ?a where {  ?a dbo:numberOfPages ?n .  };
dbo:Film;;;how much did <A> cost?;select distinct ?n where { <A> dbo:budget ?n . };select distinct ?a where {  ?a dbo:budget ?n .  };
;;;in which films did <A> as well as <B> play?;select distinct ?uri where { ?uri rdf:type dbo:Film . ?uri dbo:starring <A> . ?uri dbo:starring <B> };select distinct ?a, ?b where {  ?uri rdf:type dbo:Film . ?uri dbo:starring ?a . ?uri dbo:starring ?b  };
<http://dbpedia.org/class/yago/Actor109765278>;dbo:Film;;is <A> starring in <B>?;ask where { <A> dbo:starring <B> . };select distinct ?a, ?b where {  ?a dbo:starring ?b .  };
dbo:Broadcaster;dbo:TelevisionShow;;list all episodes of the first season of the <A> television series <B>!;select distinct ?uri where { ?uri dbo:series <B> . ?uri dbo:seasonNumber 1 . <B> dbo:network <A> };select distinct ?a, ?b where {  ?uri dbo:series ?b . ?uri dbo:seasonNumber 1 . ?b dbo:network ?a };
;;;list all the musicals with music by <A>.;select distinct ?uri where { ?uri rdf:type dbo:Musical . ?uri dbo:musicBy <A> . };select distinct ?a where {  ?uri rdf:type dbo:Musical . ?uri dbo:musicBy ?a.  };
;;;show me <A>’s autobiography ;select distinct ?uri where { ?uri dbo:author <A> . ?uri dbo:literaryGenre dbr:Autobiography. };select distinct ?a where {  ?uri dbo:author ?a . ?uri dbo:literaryGenre dbr:Autobiography  };
;;;show me all books in <A> series.;select distinct ?uri where { ?uri dbo:series <A>.  ?uri rdf:type dbo:Book};select distinct ?a where {  ?uri dbo:series ?a . ?uri rdf:type dbo:Book.  };
;;;show me the book that <A> wrote.;select distinct ?uri where { ?uri rdf:type dbo:Book . ?uri dbo:author <A>. };select distinct ?a where {  ?uri rdf:type dbo:Book . ?uri dbo:author ?a.  };
;dbo:Artwork;;to which artistic movement did the artist of the <A> belong?;select distinct ?uri where { <A> dbo:author ?person . ?person dbo:movement ?uri . ?person rdf:type dbo:Artist };select distinct ?a where {  ?a dbo:author ?person . ?person dbo:movement ?uri . ?person rdf:type dbo:Artist  };
;;;what is <A>’s real name?;select distinct ?s where { <A> dbp:alterEgo ?s . };select distinct ?a where {  ?a dbp:alterEgo ?s .  };
  1. “clickable URIBurner SPARQL link” replace dbpedia.org with linkeddata.uriburner.com .
  2. “clickable URIBurner SPARQL + Sponger link” add the parameter &sponger:get=add .
  3. “clickable URIBurner SPARQL-FED link” changes SPARQL query to a SPARQL-FED query using designated SPARQL-FED Service endpoint; with namespace declarations applied to query.
  4. Use “SPARQL Query Response” as the the label applied to the click types above
  5. “clickable URIBurner SPARQL Query Editor link” replace dbpedia.org with linkeddata.uriburner.com and replace &query parameter with &qtx.
  6. Use “URIBurner SPARQL Query Editor” as the label applied to clickable links to a “clickable URIBurner SPARQL Query Editor link”

Given the guidelines stated above, return a clickable URIBurner SPARQL-FED link (using DBpedia is the designated SPARQL-FED endpoint) for the following:
Give me all books by Charles Dickens with more than 300 pages

Q: Sure that’s a SPARQL-FED query?

A:

SPARQL Query Response

This link will return all books by Charles Dickens with more than 300 pages using DBpedia as the designated SPARQL-FED endpoint.

Screenshot 2023-05-09 at 1.28.33 PM

Q:
Redo, but returning a clickable URIBurner SPARQL-FED Query Editor link where &qtx replaces &query and DBpedia is the SPARQL-FED Query Service.

A:

URIBurner SPARQL Query Editor

This link will take you to the URIBurner SPARQL Query Editor, where you can edit and execute the query to find all books by Charles Dickens with more than 300 pages using DBpedia as the designated SPARQL-FED endpoint.