All Projects → BorderCloud → SPARQL

BorderCloud / SPARQL

Licence: other
Lib PHP for SPARQL 1.1

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to SPARQL

transparencia-dados-abertos-brasil
A survey of Brazilian states' and municipalities' transparency and open data portals, as well as institutional websites, obtained from several public data sources. 🇧🇷 Levantamento de portais estaduais e municipais de transparência e dados abertos, bem como os portais institucionais, obtido a partir de diversas fontes públicas de dados.
Stars: ✭ 46 (+100%)
Mutual labels:  wikidata, dbpedia
Mundaneum
A clojure wrapper around WikiData
Stars: ✭ 54 (+134.78%)
Mutual labels:  sparql, wikidata
WikidataQueryServiceR
An R package for the Wikidata Query Service API
Stars: ✭ 23 (+0%)
Mutual labels:  sparql, wikidata
Scholia
Wikidata scholarly profiles
Stars: ✭ 115 (+400%)
Mutual labels:  sparql, wikidata
scholia
Wikidata-based scholarly profiles
Stars: ✭ 166 (+621.74%)
Mutual labels:  sparql, wikidata
Wikibase Sdk
JS utils functions to query a Wikibase instance and simplify its results
Stars: ✭ 251 (+991.3%)
Mutual labels:  sparql, wikidata
wikiapi
JavaScript MediaWiki API for node.js
Stars: ✭ 28 (+21.74%)
Mutual labels:  wikidata
rdf2x
RDF2X converts big RDF datasets to the relational database model, CSV, JSON and ElasticSearch.
Stars: ✭ 43 (+86.96%)
Mutual labels:  sparql
wdumper
Tool for generating filtered Wikidata RDF exports
Stars: ✭ 25 (+8.7%)
Mutual labels:  wikidata
semagrow
A SPARQL query federator of heterogeneous data sources
Stars: ✭ 27 (+17.39%)
Mutual labels:  sparql
CSV2RDF
Streaming, transforming, SPARQL-based CSV to RDF converter. Apache license.
Stars: ✭ 48 (+108.7%)
Mutual labels:  sparql
wikidata-corpus
Train Wikidata with word2vec for word embedding tasks
Stars: ✭ 109 (+373.91%)
Mutual labels:  wikidata
wikidata-ontology-explorer
small website to explore ontologies on Wikidata
Stars: ✭ 16 (-30.43%)
Mutual labels:  wikidata
dac
Entity linker for the newspaper collection of the National Library of the Netherlands. Links named entity mentions to DBpedia descriptions using either a binary SVM classifier or a neural net.
Stars: ✭ 14 (-39.13%)
Mutual labels:  dbpedia
anapsid
An adaptive query processing engine for SPARQL endpoints.
Stars: ✭ 17 (-26.09%)
Mutual labels:  sparql
stardog-language-servers
Language Servers for Stardog Languages
Stars: ✭ 19 (-17.39%)
Mutual labels:  sparql
lc-wikidata
Library Carpentry Wikidata
Stars: ✭ 17 (-26.09%)
Mutual labels:  wikidata
SEPA
Get notifications about changes in your SPARQL endpoint.
Stars: ✭ 21 (-8.7%)
Mutual labels:  sparql
lsw2
OWL and Semantic Web toolkit for Common Lisp, used for construction and reasoning over ontologies and ontology-structured data
Stars: ✭ 22 (-4.35%)
Mutual labels:  sparql
ann
A repository for brainstorming and prototyping ideas related to the eLifeSprint project Annotate them all (https://sprint.elifesciences.org/annotate-them-all/)
Stars: ✭ 13 (-43.48%)
Mutual labels:  wikidata

Build Status

Lib Sparql 1.1 HTTP Client

Very simple SparqlClient for PHP.

Thanks to contributors.

Installation

This project assumes you have composer installed. Simply add new dependency via Composer:

composer require bordercloud/sparql

To your composer.json, and then you can simply install with:

composer install

Test the lib with a php script : query

You can test your first query sparql with DBPEDIA via a command line :

./bin/query -r -e http://dbpedia.org/sparql -f ./example/queryReadDBpedia.rq

And the doc of this script with virtuoso, 4store, Allegrograph, Fuseki and Sesame :

USAGE : query [-r|-w][-e URL|--endpointQueryAndUpdate=URL]
		[--file=FILE|-f FILE]
        [-v|-verbose]

    -r                                  READ ONLY
    -w                                  WRITE ONLY
    -e, --endpointQueryAndUpdate=URL    Put url of endpoint to do query or
                                        update :
                                            URL/sparql/?query=...
                                            URL/update/?update=... (POST)
    -q, --endpointQueryOnly=URL         Put url of endpoint to do query :
                                            URL?query=...
    -u, --endpointUpdateOnly=URL        Put url of endpoint to do query :
                                            URL?update=... (POST)
    --nameParameterQuery=PARAMETER      Change the name of parameter in
                                        the request http to read.
                                        (by default : query)
    --nameParameterUpdate=PARAMETER     Change the name of parameter in
                                        the request http to write.
                                        (by default : update)
    -f,--file=File                      File of the query.
    -t, --typeOutput=TYPE               Type of response: table,txt,csv,tsv,ttl,srx,srj
                                        (by default : table)

    -l, --login=LOGIN                  Server login
    -p, --password=PASSWORD            Server password

    -v, --verbose                       Mode verbose
    -d, --debug                         Mode debug

EXAMPLE : Virtuoso
./query -w -e http://localhost/tests/ -f ./example/queryWrite1.rq

./query -r -e http://localhost/tests/ -f ./example/queryRead1.rq

EXAMPLE : 4Store
./query -w -e http://localhost/ -f ./example/queryWrite1.rq

./query -r -e http://localhost/ -f ./example/queryRead1.rq

EXAMPLE : Sesame
./query -w -q http://localhost/openrdf-sesame/repositories/tests \
 -u http://localhost/openrdf-sesame/repositories/tests/statements \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/openrdf-sesame/repositories/tests \
 -u http://localhost/openrdf-sesame/repositories/tests/statements \
-f ./example/queryRead1.rq

EXAMPLE : Fuseki
./query -w -q http://localhost/tests/query \
-u http://localhost/tests/update \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/tests/query \
-u http://localhost/tests/update \
-f ./example/queryRead1.rq

EXAMPLE : Allegrograph
./query -w -q http://localhost/repositories/tests \
-u http://localhost/repositories/tests \
--nameParameterUpdate=query \
-f ./example/queryWrite1.rq

./query -r -q http://localhost/repositories/tests \
-u http://localhost/repositories/tests \
--nameParameterUpdate=query \
-f ./example/queryRead1.rq

Examples

Send a simple query to Wikidata :

<?php
use BorderCloud\SPARQL\SparqlClient;

require_once ('../vendor/autoload.php');

$endpoint = "https://query.wikidata.org/sparql";
$sc = new SparqlClient();
$sc->setEndpointRead($endpoint);
//$sc->setMethodHTTPRead("GET");
$q = "select *  where {?x ?y ?z.} LIMIT 5";
$rows = $sc->query($q, 'rows');
$err = $sc->getErrors();
if ($err) {
    print_r($err);
    throw new Exception(print_r($err, true));
}

foreach ($rows["result"]["variables"] as $variable) {
    printf("%-20.20s", $variable);
    echo '|';
}
echo "\n";

foreach ($rows["result"]["rows"] as $row) {
    foreach ($rows["result"]["variables"] as $variable) {
        printf("%-20.20s", $row[$variable]);
        echo '|';
    }
    echo "\n";
}

Send a simple query to DBpedia :

<?php
use BorderCloud\SPARQL\SparqlClient;

require_once ('../vendor/autoload.php');

$endpoint = "http://dbpedia.org/sparql";
$sc = new SparqlClient();
$sc->setEndpointRead($endpoint);
$q = "select *  where {?x ?y ?z.} LIMIT 5";
$rows = $sc->query($q, 'rows');
$err = $sc->getErrors();
if ($err) {
    print_r($err);
    throw new Exception(print_r($err, true));
}

foreach ($rows["result"]["variables"] as $variable) {
    printf("%-20.20s", $variable);
    echo '|';
}
echo "\n";

foreach ($rows["result"]["rows"] as $row) {
    foreach ($rows["result"]["variables"] as $variable) {
        printf("%-20.20s", $row[$variable]);
        echo '|';
    }
    echo "\n";
}

Send a simple query via an endpoint sparql-auth (with OpenLink Virtuoso Open-Source Edition) :

<?php
use BorderCloud\SPARQL\SparqlClient;

require_once ('../vendor/autoload.php');

$endpoint = "https://example.com/sparql-auth";
$sc = new SparqlClient();
$sc->setEndpointRead($endpoint);
//$sc->setEndpointWrite($endpoint);
$sc->setLogin("login");
$sc->setPassword("password");

$q = "select *  where {?x ?y ?z.} LIMIT 5";
$rows = $sc->query($q, 'rows');
$err = $sc->getErrors();
if ($err) {
    print_r($err);
    throw new Exception(print_r($err, true));
}

foreach ($rows["result"]["variables"] as $variable) {
    printf("%-20.20s", $variable);
    echo '|';
}
echo "\n";

foreach ($rows["result"]["rows"] as $row) {
    foreach ($rows["result"]["variables"] as $variable) {
        printf("%-20.20s", $row[$variable]);
        echo '|';
    }
    echo "\n";
}

Documentation

Copy Sources and tests

git clone http://github.com/BorderCloud/SPARQL.git
composer install

Before to execute tests, you need to start database's instances. For example, Virtuoso 7

systemctl start docker
docker pull bordercloud/tft-virtuoso7-stable
docker run --privileged --name instance.tft_virtuoso7_stable -h tft_virtuoso7_stable -d bordercloud/tft-virtuoso7-stable

Execute PHPUnit

phpunit --configuration phpunit.xml --coverage-text

Contact

If you have remarks, questions, or suggestions, please send them to [email protected]

Release-Notes

  • V2.1.0 ** Add tools to detect SPARQL update queries ** Add the timeout parameter at the send of the query

  • V2.0.9 ** Fix : bugs in SPARQL client

  • V2.0.8 ** Fix : bugs when there are error messages of SPARQL services

  • V2.0.7 ** Fix : Insert the parameter User-agent in the header HTTP (for Wikidata)

  • V2.0.6 ** Fix : bug with the parser and the ASK query's results

  • V2.0.5 ** Compatibility : PHP 7.1 and psr-4 ** Rename the class Endpoint to SparqlClient and simplify the constructor. You can set the endpoints only by their setters. ** Rename several functions (PHP Lint) ** Update PHPDoc ** Add the function SparqlClient->getLastErreur() : can read the SPARQL syntax error directly, if the pattern of error exists (Add the pattern of Wikidata and Virtuoso) ** Move files and add tests + phpunit.xml. SparqlClient is coverage to 82% for the moment (coverage with Virtuoso and Wikidata). ** Enable Travis in GitHub

  • V1.2.1.0 Add fix for Wikidata and other

  • V1.1.0.0 version SPARQL.Pro lib PHP by Karima Rafes [email protected]

license

SPARQL.Pro lib PHP (c)2019 by Karima Rafes - BorderCloud

SPARQL.Pro lib PHP is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

You should have received a copy of the license along with this work. If not, see http://creativecommons.org/licenses/by-sa/4.0/.

Compile DOC

php vendor/clean/phpdoc-md/bin/phpdoc-md

Git...

Modify also the version in composer.json

git pull
git push
git tag -a 2.0.8@dev -m "version dev"
git push --tags
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].