Code Monkey home page Code Monkey logo

ot-llm's Introduction

SPARQL generation for DKG Artworks using GPT models

The main file is main_system.py, which uses GPT to generate SPARQL queries for the artwork data in the OriginTrail DKG.

How to run

In a Terminal, assuming packages are installed:

python main.py

The server should be up at 127.0.0.1:5000.

Examples of outputs

Give me all artworks whose name contains 'aleksa':

SELECT ?artwork ?name ?description ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:name ?name;
           schema:description ?description;
           schema:image ?image;
           schema:author ?author.
  FILTER(CONTAINS(?name, "aleksa"))
}
------------------------
[]
------------------------------------------------------------------
Give me all artworks where author is 'aleksa':

SELECT ?artwork ?name ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:author ?author.
  FILTER(CONTAINS(?author, "aleksa"))
}
------------------------
[]
------------------------------------------------------------------
Give me all artworks related to fairies:

SELECT ?artwork ?name ?description ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:keywords ?keywords;
           schema:name ?name;
           schema:description ?description;
           schema:image ?image;
           schema:author ?author.
  FILTER (CONTAINS(?keywords, "fairy"))
}
------------------------
[]
------------------------------------------------------------------
Give me all artworks related to fairies and elves, and their locations:

SELECT ?artwork ?name ?description ?image ?author ?location WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:keywords ?keyword;
           schema:name ?name;
           schema:description ?description;
           schema:image ?image;
           schema:author ?author.
  FILTER (CONTAINS(?keyword, "fairy") || CONTAINS(?keyword, "elf"))
  OPTIONAL { ?artwork schema:location ?location }
}
------------------------
[]
------------------------------------------------------------------
Show me artworks containing humans:

SELECT ?artwork ?name ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:name ?name;
           schema:image ?image;
           schema:author ?author;
           schema:keywords ?keywords.
  FILTER (CONTAINS(?keywords, "human")).
}
------------------------
[]
------------------------------------------------------------------
Show me artworks containing humans with black hair:

SELECT ?artwork ?name ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:additionalProperty/schema:name "hair";
           schema:additionalProperty/schema:value "black";
           schema:additionalProperty/schema:name "attires";
           schema:additionalProperty/schema:value ?attires;
           schema:image ?image;
           schema:author ?author;
  FILTER(CONTAINS(?attires, "human"))
}
------------------------
[]
------------------------------------------------------------------
Show me artworks that are related to anime:

SELECT ?artwork ?name ?description ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:keywords ?keyword;
           schema:name ?name;
           schema:description ?description;
           schema:image ?image;
           schema:author ?author.
  FILTER (CONTAINS(?keyword, "anime"))
}
------------------------
[{'artwork': 'https://t.co/gCHdCKJl75', 'author': '_:t1977794', 'image': 'https://t.co/gCHdCKJl75', 'name': '"anime guy"', 'description': '"wow cool"'}]
------------------------------------------------------------------
Show me some artwork on DKG with a flower motive:

SELECT ?artwork ?name ?image
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:keywords ?keywords.
  FILTER (CONTAINS(?keywords, "flower")).
  ?artwork schema:name ?name;
           schema:image ?image.
}
------------------------
[]
------------------------------------------------------------------
Show me some artwork that can be described as 'cool':

SELECT ?artwork ?name ?description ?image ?author
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:keywords ?keywords;
           schema:name ?name;
           schema:description ?description;
           schema:image ?image;
           schema:author ?author.
  FILTER (CONTAINS(?keywords, "cool"))
}
------------------------
[]
------------------------------------------------------------------
Give me all artworks, their names, and descriptions from author with name Leonardo Da Vinci:

SELECT ?artwork ?name ?description
WHERE {
  ?artwork rdf:type schema:VisualArtwork;
           schema:author [
             rdf:type schema:Person;
             schema:name "Leonardo Da Vinci"
           ];
           schema:name ?name;
           schema:description ?description.
}
------------------------
[]
------------------------------------------------------------------

ot-llm's People

Contributors

aleksamagicka avatar

Watchers

 avatar Kostas Georgiou avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.