RDFIO-Mediawiki Extension: Difference between revisions

From artserver wiki
No edit summary
Line 1: Line 1:
RDFIO is a Mediawiki extension which:
{{#set: Section=Code_Notes|
Date=2020}}
 
[https://www.mediawiki.org/wiki/Extension:RDFIO RDFIO] is a Mediawiki extension which:
* adds  SPARQL Endpoint to SMW installtion
* adds  SPARQL Endpoint to SMW installtion
* imports RDFs into the wiki
* imports RDFs into the wiki
* queries remote SPARQL endpoint URL
* queries remote SPARQL endpoint URL
To me it is quite interesting to be able to have a SPARQL endpoint in a wiki, without having to [https://www.semantic-mediawiki.org/wiki/Help:Using_SPARQL_and_RDF_stores setup a RDF store]], which to the extent of my knowldge, disables SMW's [[Special:Ask|ask queries]], forcing users to use only the SPARQL endpoint. So RDFIO seems to combine the best of both approaches.                                         


==Related Work==
==Related Work==
Line 13: Line 18:
However, as described in the following [https://github.com/rdfio/RDFIO/issues/65 issue]: the extension development team is having a hard time to keep up with the development and deployment rate of Mediawiki. So for the moment, '''for Mediawiki 1.34.1, the branch <code>59-make-work-with-mw-1.34 should be checkout</code>'''.
However, as described in the following [https://github.com/rdfio/RDFIO/issues/65 issue]: the extension development team is having a hard time to keep up with the development and deployment rate of Mediawiki. So for the moment, '''for Mediawiki 1.34.1, the branch <code>59-make-work-with-mw-1.34 should be checkout</code>'''.


  cd extensions/Rdfio
php composer.phar require rdfio/rdfio --update-no-dev
  cd extensions/
mv Rdfio/ Rdfio.bak
git clone https://github.com/rdfio/RDFIO.git Rdfio
cd Rdfio
  git checkout 59-make-work-with-mw-1.34
  git checkout 59-make-work-with-mw-1.34
  php ../../maintenance/update.php
  php ../../maintenance/update.php
rm -r ../Rdfio.bak
Once done in the page [[Special:RDFIOAdmin]] it should read: "The triplestore is already set up"
=== Settings ===
I have added the following settings to LocalSettings.php, so that the SPARQL endpoint is accessible to non-logged in users, but editind (insert statments are disabled)
# ---------------------------------------------------------------
#  RDFIO Configuration
# ---------------------------------------------------------------
$rdfiogAllowRemoteEdit = false;
$wgGroupPermissions['*']['rdfio-sparql'] = true;


Once done in the page Special:RDFIOAdmin it should read: "The triplestore is already set up"


== import RDF==
== import RDF==
using Rdfio/maintenance/importRdf.php it is possible to import to the wiki RDF files. As example I will import  [https://www.w3.org/People/Berners-Lee/card Tim Berners Lee FOAF card]  
using Rdfio/maintenance/importRdf.php it is possible to import to the wiki RDF files. As example I will import  [https://www.w3.org/People/Berners-Lee/card Tim Berners Lee FOAF card]
  php importRdf.php --server http://localhost --in ~/Documents/Projects/RDF/LearningSparql/TimBernersLee.ttl
  php importRdf.php --server http://localhost --in ~/Documents/Projects/RDF/LearningSparql/TimBernersLee.ttl


Line 27: Line 47:


== SPARQL Query==
== SPARQL Query==
Now that TBL FOAF se can use the Special:SPARQLEndpoint to query it
We can user [[Special:SPARQLEndpoint]] to query the wiki property & values
 
Note: that despite runing the update.php and runJobs.php I needed to perform a refresh action on the pages with Semantic annotation so that the RDFIO could ''pick it them up''.
 


<source lang="sparql>
<source lang="sparql>
@PREFIX w: <http://localhost/beerwiki/index.php/Special:URIResolver/> .
@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf: <http://xmlns.com/foaf/0.1/>.


SELECT *
SELECT *
WHERE { ?s ?p "Timothy Berners-Lee" }
WHERE { ?s ?p ?v }
LIMIT 25
LIMIT 200
</source>
</source>




<source lang="sparql">
<source lang="sparql">
@PREFIX w : <http://localhost/beerwiki/index.php/Special:URIResolver/> .
@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf: <http://xmlns.com/foaf/0.1/>.
 


SELECT *
SELECT *
WHERE { ?s w:Property-3AName ?val }
WHERE { ?s ?p "André Castro" }
LIMIT 25
LIMIT 25
</source>
</source>


 
Who knows who
<source lang="sparql">
<source lang="sparql">
@PREFIX w: <http://localhost/beerwiki/index.php/Special:URIResolver/> .
@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf : <http://xmlns.com/foaf/0.1/> .
@PREFIX foaf : <http://xmlns.com/foaf/0.1/> .


SELECT *
SELECT *
WHERE { ?s foaf:homepage ?v }
WHERE { ?s foaf:knows ?v }
LIMIT 25
LIMIT 25
</source>
</source>
==Furture Research==
* can we use RDIO to query external SPARQL endoints and bring the results to the wiki? ''Don't think so''
* can we embbed SPARQL queries in wiki pages?
* use Python's [https://rdflib.readthedocs.io/en/stable/gettingstarted.html RDFlib] to query the wiki, as explified in [https://janakiev.com/blog/wikidata-mayors/ Where do Mayors Come From: Querying Wikidata with Python and SPARQL]


==References==
==References==

Revision as of 10:20, 15 May 2020


RDFIO is a Mediawiki extension which:

  • adds SPARQL Endpoint to SMW installtion
  • imports RDFs into the wiki
  • queries remote SPARQL endpoint URL

To me it is quite interesting to be able to have a SPARQL endpoint in a wiki, without having to setup a RDF store], which to the extent of my knowldge, disables SMW's ask queries, forcing users to use only the SPARQL endpoint. So RDFIO seems to combine the best of both approaches.

Related Work

The article RDFIO: extending Semantic MediaWiki for interoperable biomedical data management[1] was quite eye opening, as to how RDFIO can be used to expand the territory of Mediawiki + Semantic Mediawiki into Semantic Web, in "usage scenarios such as bootstrapping new wikis from existing data sources, or round-tripping between the SMW data structure and the RDF data format used in the wider Semantic Web, "

Installing

Installation of RDFIO is simple, if the installation steps are followed.

However, as described in the following issue: the extension development team is having a hard time to keep up with the development and deployment rate of Mediawiki. So for the moment, for Mediawiki 1.34.1, the branch 59-make-work-with-mw-1.34 should be checkout.

php composer.phar require rdfio/rdfio --update-no-dev
cd extensions/
mv Rdfio/ Rdfio.bak
git clone https://github.com/rdfio/RDFIO.git Rdfio
cd Rdfio
git checkout 59-make-work-with-mw-1.34
php ../../maintenance/update.php
rm -r ../Rdfio.bak

Once done in the page Special:RDFIOAdmin it should read: "The triplestore is already set up"

Settings

I have added the following settings to LocalSettings.php, so that the SPARQL endpoint is accessible to non-logged in users, but editind (insert statments are disabled)

# ---------------------------------------------------------------
#  RDFIO Configuration
# ---------------------------------------------------------------
$rdfiogAllowRemoteEdit = false;
$wgGroupPermissions['*']['rdfio-sparql'] = true;


import RDF

using Rdfio/maintenance/importRdf.php it is possible to import to the wiki RDF files. As example I will import Tim Berners Lee FOAF card

php importRdf.php --server http://localhost --in ~/Documents/Projects/RDF/LearningSparql/TimBernersLee.ttl

That import will probably add a few Jobs to be MW queue which need to be run:

 php ../../maintenance/update.php

SPARQL Query

We can user Special:SPARQLEndpoint to query the wiki property & values

Note: that despite runing the update.php and runJobs.php I needed to perform a refresh action on the pages with Semantic annotation so that the RDFIO could pick it them up.


@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf: <http://xmlns.com/foaf/0.1/>.

SELECT *
WHERE { ?s ?p ?v }
LIMIT 200


@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf: <http://xmlns.com/foaf/0.1/>.


SELECT *
WHERE { ?s ?p "André Castro" }
LIMIT 25

Who knows who

@PREFIX w : <http://oooooooooo.io/index.php/Special:URIResolver/> .
@PREFIX foaf : <http://xmlns.com/foaf/0.1/> .

SELECT *
WHERE { ?s foaf:knows ?v }
LIMIT 25

Furture Research


References

  1. Lampa, S., Willighagen, E., Kohonen, P. et al. RDFIO: extending Semantic MediaWiki for interoperable biomedical data management. J Biomed Semant 8, 35 (2017). https://doi.org/10.1186/s13326-017-0136-y
... more about "RDFIO-Mediawiki Extension"
Code_Notes +
Date"Date" is a type and predefined property provided by Semantic MediaWiki to represent date values.
2020 +