Giter Club home page Giter Club logo

gosparqled's Introduction

GoDoc Build Status

Gosparqled - SPARQL Auto-Completion

Gosparqled provides a library for retrieving context-aware recommendations for a SPARQL query. The library is written in GO and is then translated into JavaScript using GopherJS.

Gosparqled demo

What is context-aware ?

By context-aware recommendation, I mean that all patterns which are connected to the element to recommend participate in the recommendation. For example, the 3rd pattern below is left out of the context of the recommendation. The reason is that none of its variables appear in the others. However, the 2nd is kept.

?s rdf:type %% RECOMMEND HERE! %% .
?s foaf:name ?name .
?o ?p "left out" .

Demo

The folder demo/ shows how gosparqled can be used with other tools such as YASR and YASQE in order to have a full-fledged SPARQL query editor with the added recommendation feature. That demo can be tested at http://scampi.github.io/gosparqled/.

Auto-Completion

The recommendations are context-aware, i.e., the current state of the SPARQL query is taken into consideration when retrieving the recommendations.

In the examples below, the character < represents the position in the query to auto-complete by pressing CTRL + SPACE. The < should not be typed prior to pressing the key combination. The auto-completion is possible at any position in a triple pattern.

Class

Recommend possible classes:

SELECT * {
    ?s a <
}

Predicate

Recommend possible predicates:

SELECT * {
    ?s <
}

Relation

Recommend possible relations between a Person and a Document:

SELECT * {
    ?s a <Person> .
    ?o a <Document> .
    ?s < ?o
}

Keyword

Recommend possible terms (e.g., classes or predicates) which URI contains a keyword, case-insensitive. Below, it presents classes which contain the word movie:

SELECT * {
    ?s a Movie<
}

Path

Recommend possible path of a fixed length, written as X/. Below, recommendations about paths of lengths 2 between a Movie and a Person are returned:

SELECT * {
    ?s a <Movie> .
    ?o a <Person> .
    ?s 2/< ?o
}

Prefix

Recommend possible terms (e.g., classes or predicates) with the given prefix. Below, it presents only the predicates within the rdfs prefix:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT * {
    ?s rdfs:<
}

Content

Recommend content elements, e.g., literals, URIs, either at the subject or the object location.

  • Auto-completion on the object. This returns a sample of the labels, probably literals.

    SELECT * {
        ?s rdfs:label <
    }
  • Auto-completion on the subject. This returns a list of URIs which name is John.

    SELECT * {
        < foaf:name "John" .
    }

Building

First, install GopherJS:

$ go get github.com/gopherjs/gopherjs

Run the command below to create the JavaScript library. The -m flag minifies the generated JavaScript code.

$ gopherjs build -m

The following methods can then be called via JavaScript (see demo/autocompletion.js).

  • RecommendationQuery in the autocompletion namespace

    It takes in the SPARQL query with the character < indicating the position in the query to auto-complete. It returns the processed SPARQL query, which can then be sent to the SPARQL endpoint in order to retrieve the possible recommendations. The recommendations are bound to the variable ?POF.

Publication

This library is presented in http://ceur-ws.org/Vol-1272/paper_157.pdf. If you are using this tool, please cite this work.

Addendum

The ?POF variable excludes predicates that match rdf:type.

FILTER(?POF != <http://www.w3.org/1999/02/22-rdf-syntax-ns#type>)

gosparqled's People

Contributors

scampi avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

gosparqled's Issues

Limit/Offset parse error

The following query causes a parse error with the gosparqled JS library.

SELECT * WHERE {
    ?sub a 
}
OFFSET 10
LIMIT 10

Stack trace:

Failed to process query

parse error near Unknown (line 1 symbol 1 - line 1 symbol 1):

parse error near ws (line 2 symbol 11 - line 2 symbol 12):

parse error near Action13 (line 2 symbol 12 - line 2 symbol 12):

parse error near skip (line 2 symbol 11 - line 2 symbol 12):

parse error near ISA (line 2 symbol 10 - line 2 symbol 12):
a 
parse error near endOfLine (line 3 symbol 0 - line 3 symbol 1):


parse error near ws (line 3 symbol 0 - line 3 symbol 1):


parse error near Action13 (line 3 symbol 1 - line 3 symbol 1):

parse error near skip (line 3 symbol 0 - line 3 symbol 1):


parse error near Action8 (line 3 symbol 1 - line 3 symbol 1):

parse error near objectPath (line 2 symbol 12 - line 3 symbol 1):
< 

parse error near objectListPath (line 2 symbol 12 - line 3 symbol 1):
< 

parse error near endOfLine (line 5 symbol 0 - line 5 symbol 1):


parse error near ws (line 5 symbol 6 - line 5 symbol 7):

parse error near Action13 (line 0 symbol 0 - line 0 symbol 0):

parse error near skip (line 0 symbol 0 - line 0 symbol 0):

parse error near INTEGER (line 5 symbol 7 - line 0 symbol 0):
10
parse error near limit (line 5 symbol 1 - line 0 symbol 0):
limit 10
parse error near groupGraphPattern (line 1 symbol 16 - line 4 symbol 1):
{
    ?sub a < 
}

parse error near whereClause (line 1 symbol 10 - line 4 symbol 1):
WHERE {
    ?sub a < 
}

parse error near Action13 (line 1 symbol 1 - line 1 symbol 1):

parse error near prolog (line 1 symbol 1 - line 1 symbol 1):

parse error near Unknown (line 1 symbol 1 - line 1 symbol 1):

Access at two endpoint

Hello,

I have a question, I use your developpement and I need to connect two endpoint for one application.
In fact one connection for a specify schema (and autocompletion) and second connection for query.
I search on this code but I have not see where I add the function.

Thank in advance.

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.