Git Product home page Git Product logo

simplegraphdb's Introduction

Simple Graph Database - A Hexastore based Triple Store Build Status


Developed to help learn the Golang language, this project explores a simple form of graph database, the Triple Store, by implementing the Hexastore architecture from the paper "Hexastore: Sextuple Indexing for Semantic Web Data Management". The project also explores the SPARQL graph query language, by implementing a simplified version of it which I dubbed simplesparql.

Introduction - Usage

As a simple demo, we can scrape your Twitter network and query it with this library. To do so:

  1. git clone this library to your designated Go workspace
  2. Go into the scripts/ directory
  3. Install script dependencies with pip install -r requirements.txt (consider using virtualenv).
  4. Run ./create_twitter_followers_graph_example_db.sh. Note: If you don't have a Twitter account, skip this step and a default Twitter network (mine) will be used.
  5. Go into the /examples/your_twitter_graph/ folder and run go build
  6. A binary is created, which you can run with ./your_twitter_graph
  7. Query the n etwork with simplesparql syntax (See the README.md section on it below).
Example starting query

Get all the people that you follow with:

SELECT ?x WHERE { '<YOUR SCREEN NAME>' 'follows' ?x }

Usage - Golang Package

1 .Add to project:

go get github.com/thundergolfer/simplegraphdb or glide get github.com/thundergolfer/simplegraphdb

  1. Add to imports:
import (
  "github.com/thundergolfer/simplegraphdb"
)

Package Interface

InitHexastoreFromJSONRows(filename string) (*HexastoreDB, error)

You can setup a Hexastore by passing a filepath to a .json file with the following format:

{"subject": <STRING>, "prop": <STRING>, "object": <STRING>}
{"subject": <STRING>, "prop": <STRING>, "object": <STRING>}
{"subject": <STRING>, "prop": <STRING>, "object": <STRING>}
...
...
InitHexastoreFromTurtle(dbFilePath string) (Hexastore, error)

BETA: Turtle files are currently parsed with d4l3k/turtle, which is quite limited.

Turtle (Terse RDF Triple Language) is a syntax for describing RDF semantic web graphs. You can load an RDF graph specified in turtle syntax with this function.

RunQuery(query string, store Hexastore) (string, error)

Run a well-formed simplesparql query (see more below) against a Hexastore instance. Just returns a printable table of results like:

?target                | ?prop                  |
------------------------------------------------
Cow                    | follows                |
Apple                  | follows                |
SaveToJSONRows(filename string, store Hexastore) error

Not yet implemented, but coming soon


simplesparql

simplesparql is an implementation of a subset of the SPARQL query language. It supports the asking of basic questions about a graph, questions like "Who likes 'Manchester United'?", but not anything involving aggregations, grouping, conditionals. With time, these things may be implemented.

The basics of it are that you preface variables with ?, with a variable in the WHERE clause acting like a wildcard (*). For example:

SELECT ?screen_name WHERE { 'jonobelotti_IO' 'follows' ?screen_name }

will return all people that jonobelotti_IO follows (ie. all vertices on the graph connected by a 'follows' edge from the vertice 'jonobelotti_IO'.

You can use up to a maximum of 3 variables in a WHERE clause. All WHERE clauses must have exactly three components. For example:

SELECT ?screen_name, ?property WHERE { 'jonobelotti_IO' ?property ?screen_name }

will essentially return all triples in the graph involving the 'jonobelotti_IO' vertice.

simplegraphdb's People

Contributors

thundergolfer-two avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

simplegraphdb's Issues

Nested SELECT queries will break quite badly

Current query system is not setup to handle much beyond the most basic of SPARQL queries. If subqueries are to be a thing, non-trivial changes will need to be made to the:

  • Query engine (!!)
  • Query validation functionality
  • Query parser

Turtle parsing golang library is quite limited

d4l3k/turtle is the library I'm using to parse Turtle RDF files. It can't handle RDF 'Bags', so I've had to fork it and fix that. It also doesn't seem to handle other features of the Turtle syntax, meaning it is unsuitable for loading and manipulating a lot of the downloadable online Turtle RDF Graphs.

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.