Re: Demo: Query Language Cheatsheet Generation using ChatGPT 3.5

Hi Kingsley,
Thank you so much.I get the grin too. Things are as they are.
Best,
Adam






On Tue, May 2, 2023 at 4:53 PM Kingsley Idehen <kidehen@openlinksw.com>  wrote:
Hi Adasal,


On 5/2/23 8:32 AM, adasal wrote:
Hi Kingsley, 
This is brilliant.  You might have seen my last email about GPT 3.5 compared to
4 going over your last post?  


Yes, I posted a reply.





I had thought that they would be good for producing SPARQL, though.  


That's the next step. I wanted to start with very basic examples that showcase
the most basic aspects of hyperlinks functioning as entity names that manifest a
giant global entity relationship graph (a/k/a a Semantic Web).





You have shown my assumption to be correct.  
Do you have any thoughts about producing the whole life cycle?  


I am a little unclear about what you mean by "whole life cycle?" question. 






I'm a non-technical outsider.  My understanding is that linked data, in terms of
URLs, guarantees origin of documents which it retrieves according to a possibly
complex logical request.  


Yes.



But the original documents have to be annotated in the first place.  


They have to describe whatever the hyperlink denotes. 






So, for instance, Wikidata "..acts as central storage for thestructured data of
its Wikimedia sister projects including Wikipedia, Wikivoyage, Wiktionary,
Wikisource, and others."  
There is a life cycle from Wikipedia to a representation in Wikidata.  


Yes.





How is this accomplished and could eg ChatGPT, help?  


ChatGPT simply offers tools for productivity understanding the end product of
following certain "best practices" for structured data representation using
entity relationship graphs constructed using hyperlinks.

Wikidata has an annotation system to drives how its data is derived from
Wikipedia content en route to publication using Linked Data principles, that's
it :)




Kingsley 




Adam Saltiel  





On Mon, May 1, 2023 at 10:13 PM Kingsley Idehen <kidehen@openlinksw.com>  wrote:
All,

ChatGPT 3.5 is less capable that 4.0, but much faster. Here’s a transcript
demonstrating the creation of SQL and SPARQL cheatsheets – that I just generated
(whimsically). 

TRANSCRIPT
Q: Make a simple SQL Cheatsheet.
Q: Redo, but using a Table for enhanced presentation.
Q: Redo the SQL cheatsheet using a Markdown Table in a code-block.
A:
Sure, here is the SQL cheatsheet presented in a markdown table inside a code
block:

Command  Description  SELECT  Retrieves data from one or more tables  SELECT
column1, column2, ... FROM table_name;  
DISTINCT  Retrieves unique values  SELECT DISTINCT column_name FROM table_name; 
 
WHERE  Filters records based on a condition  SELECT column1, column2, ... FROM
table_name WHERE condition;  
AND/OR  Combines multiple conditions  SELECT column1, column2, ... FROM
table_name WHERE condition1 AND/OR condition2;  
ORDER BY  Sorts the result set  SELECT column1, column2, ... FROM table_name
ORDER BY column_name ASC/DESC;  
LIMIT  Limits the number of results returned  SELECT column1, column2, ... FROM
table_name LIMIT number_of_rows;  
JOIN  Combines rows from two or more tables based on a related column between
them  SELECT column1, column2, ... FROM table1 JOIN table2 ON table1.column_name
= table2.column_name;  
GROUP BY  Groups rows based on a column  SELECT column1, COUNT(column2) FROM
table_name GROUP BY column1;  
HAVING  Filters groups based on a condition  SELECT column1, COUNT(column2) FROM
table_name GROUP BY column1 HAVING COUNT(column2) > value;  
INSERT INTO  Inserts new records into a table  INSERT INTO table_name (column1,
column2, ...) VALUES (value1, value2, ...);  
UPDATE  Modifies existing records in a table  UPDATE table_name SET column1 =
value1, column2 = value2, ... WHERE condition;  
DELETE FROM  Deletes records from a table  DELETE FROM table_name WHERE
condition;  
I hope this presentation is helpful and easy to read.

Q: Redo, with an examples column using Northwind
A:
Sure, here is an updated SQL cheatsheet presented in a markdown table inside a
code block with an additional column for actual usage examples based on the
Northwind database schema:

Command  Description  Example  SELECT  Retrieves data from one or more tables  
SELECT ProductName, UnitPrice FROM Products;  DISTINCT  Retrieves unique values 
 SELECT DISTINCT CategoryID FROM Products;  WHERE  Filters records based on a
condition  SELECT ProductName, UnitPrice FROM Products WHERE UnitPrice > 20;  
AND/OR  Combines multiple conditions  SELECT ProductName, UnitPrice FROM
Products WHERE CategoryID = 1 AND Discontinued = 0;  ORDER BY  Sorts the result
set  SELECT ProductName, UnitPrice FROM Products ORDER BY UnitPrice DESC;  LIMIT 
 Limits the number of results returned  SELECT ProductName, UnitPrice FROM
Products LIMIT 10;  JOIN  Combines rows from two or more tables based on a
related column between them  SELECT Products.ProductName, Suppliers.CompanyName
FROM Products JOIN Suppliers ON Products.SupplierID = Suppliers.SupplierID;  
GROUP BY  Groups rows based on a column  SELECT CategoryID, COUNT(*) FROM
Products GROUP BY CategoryID;  HAVING  Filters groups based on a condition  
SELECT CategoryID, COUNT(*) FROM Products GROUP BY CategoryID HAVING COUNT(*) >
5;  INSERT INTO  Inserts new records into a table  INSERT INTO Products
(ProductName, UnitPrice) VALUES ('Chai', 18.00);  UPDATE  Modifies existing
records in a table  UPDATE Products SET UnitPrice = 20 WHERE ProductID = 1;  
DELETE FROM  Deletes records from a table  DELETE FROM Products WHERE ProductID
= 1;  I hope this updated version of the SQL cheatsheet with examples based on
the Northwind database schema is helpful for you to practice with.  

Q: Repeat, for SPARQL using DBpedia for examples.
A:
Sure, here is the SPARQL cheatsheet presented in a markdown table inside a code
block with an additional column for actual usage examples using DBpedia for the
examples:

Command  Description  Example  SELECT  Retrieves data from one or more RDF
graphs  SELECT ?person ?birthdate WHERE { ?person dbo:birthDate ?birthdate }
LIMIT 10  DISTINCT  Retrieves unique values  SELECT DISTINCT ?category WHERE {
?product dcterms:subject ?category }  WHERE  Filters RDF triples based on a
condition  SELECT ?film WHERE { ?film rdf:type dbo:Film . ?film dbo:starring
dbr:Harrison_Ford . }  FILTER  Filters query results based on a condition  
SELECT ?film WHERE { ?film rdf:type dbo:Film . ?film dbo:budget ?budget .
FILTER(?budget > 100000000) }  UNION  Combines the results of two or more
queries  SELECT ?name WHERE { { ?person foaf:name ?name } UNION { ?organization
foaf:name ?name } }  OPTIONAL  Retrieves optional RDF triples  SELECT ?book
?author WHERE { ?book rdf:type dbo:Book . OPTIONAL { ?book dbo:author ?author }
}  ORDER BY  Sorts the query results  SELECT ?person ?birthdate WHERE { ?person
dbo:birthDate ?birthdate } ORDER BY DESC(?birthdate) LIMIT 10  LIMIT  Limits the
number of results returned  SELECT ?person WHERE { ?person rdf:type dbo:Person }
LIMIT 10  GROUP BY  Groups query results based on a variable  SELECT ?category
(COUNT(?product) AS ?count) WHERE { ?product dcterms:subject ?category } GROUP
BY ?category  HAVING  Filters groups based on a condition  SELECT ?category
(COUNT(?product) AS ?count) WHERE { ?product dcterms:subject ?category } GROUP
BY ?category HAVING (COUNT(?product) > 100)  Note: The examples above assume the
use of the DBpedia SPARQL endpoint (https://dbpedia.org/sparql). If you want to
test these queries, you can use the DBpedia SPARQL endpoint or install your own
copy of DBpedia.

Q: Redo for SPARQL including DESCRIBE, CONSTRUCT, COPY, and MOVE commands
A:
Sure, here is the SPARQL cheatsheet presented in a markdown table inside a code
block with additional commands and actual usage examples using DBpedia for the
examples:

Command  Description  Example  SELECT  Retrieves data from one or more RDF
graphs  SELECT ?person ?birthdate WHERE { ?person dbo:birthDate ?birthdate }
LIMIT 10  DISTINCT  Retrieves unique values  SELECT DISTINCT ?category WHERE {
?product dcterms:subject ?category }  WHERE  Filters RDF triples based on a
condition  SELECT ?film WHERE { ?film rdf:type dbo:Film . ?film dbo:starring
dbr:Harrison_Ford . }  FILTER  Filters query results based on a condition  
SELECT ?film WHERE { ?film rdf:type dbo:Film . ?film dbo:budget ?budget .
FILTER(?budget > 100000000) }  UNION  Combines the results of two or more
queries  SELECT ?name WHERE { { ?person foaf:name ?name } UNION { ?organization
foaf:name ?name } }  OPTIONAL  Retrieves optional RDF triples  SELECT ?book
?author WHERE { ?book rdf:type dbo:Book . OPTIONAL { ?book dbo:author ?author }
}  ORDER BY  Sorts the query results  SELECT ?person ?birthdate WHERE { ?person
dbo:birthDate ?birthdate } ORDER BY DESC(?birthdate) LIMIT 10  LIMIT  Limits the
number of results returned  SELECT ?person WHERE { ?person rdf:type dbo:Person }
LIMIT 10  GROUP BY  Groups query results based on a variable  SELECT ?category
(COUNT(?product) AS ?count) WHERE { ?product dcterms:subject ?category } GROUP
BY ?category  HAVING  Filters groups based on a condition  SELECT ?category
(COUNT(?product) AS ?count) WHERE { ?product dcterms:subject ?category } GROUP
BY ?category HAVING (COUNT(?product) > 100)  DESCRIBE  Retrieves RDF triples
that describe a resource  DESCRIBE <http://dbpedia.org/resource/Barack_Obama>  
CONSTRUCT  Generates an RDF graph based on a query pattern  CONSTRUCT { ?book
dbo:author ?author } WHERE { ?book rdf:type dbo:Book . ?book dbo:author ?author
}  COPY  Copies a named graph from one location to another  COPY 
<http://example.org/graph1>  TO <http://example.org/graph2>  MOVE  Moves a named
graph from one location to another  MOVE <http://example.org/graph1>  TO 
<http://example.org/graph2>  Note: The examples above assume the use of the
DBpedia SPARQL endpoint (https://dbpedia.org/sparql). If you want to test these
queries, you can use the DBpedia SPARQL endpoint or install your own copy of
DBpedia.

Received on Tuesday, 2 May 2023 16:56:11 UTC