Saturday, July 17, 2010

Setting up a local Semantic MediaWiki with RDFIO and SPARQL support

My now former student Samuel is doing a really cool Google Summer of Code project on import and export of RDF from a Semantic MediaWiki server. His screencast of today shows very nicely where things are going!

So, time to get something installed on my Ubuntu system, based on Samuel description here:
  1. sudo aptitude install mediawiki-extensions php-apc imagemagick texlive-latex-base gs-gpl cjk-latex
  2. configure MediaWiki
    1. zcat /usr/share/doc/mediawiki/README.Debian.gz | more
    2. follow instructions on
    3. create a MySQL account as described here
    4. do config stuff at http://localhost/mediawiki/config/index.php
  3. set up a save place for local checkouts for MediaWiki extensions
    1. sudo mkdir -p /usr/local/lib/mediawiki/extensions
    2. sudo chown egonw:egonw -R /usr/local/lib/mediawiki
  4. configure Semantic MediaWiki
    1. cd /usr/local/lib/mediawiki/extensions
    2. svn checkout
    3. cd /var/lib/mediawiki/extensions
    4. sudo ln -s /usr/local/lib/mediawiki/extensions/SemanticMediaWiki
    5. sudo nano /var/lib/mediawiki/LocalSettings.php
      1. add: include_once("/var/lib/mediawiki/extensions/SemanticMediaWiki/SemanticMediaWiki.php");
      2. add: enableSemantics('localhost');
      3. add: $smwgShowFactbox= SMW_FACTBOX_NONEMPTY;
    6. visit http://localhost/mediawiki/indSpecial:SMWAdminSpecial:SMWAdminex.php/Special:SMWAdmin
Next step is to install Samuel's extension in its requirements:
  1. set up the required extensions SMWWriter and POM:
    1. cd /usr/local/lib/mediawiki/extensions
    2. svn checkout
    3. svn checkout
    4. cd /var/lib/mediawiki/extensions
    5. sudo ln -s /usr/local/lib/mediawiki/extensions/SMWWriter
    6. sudo ln -s /usr/local/lib/mediawiki/extensions/PageObjectModel/
  2. apply the patch (where is it filed upstream?)
    1. cd SMWWriter
    2. wget
    3. patch -p0 < smwwriter-fixesfor-rdfio-20100716-r2.patch
  3. set up the RDFIO work from Samuel
    1. cd /usr/local/lib/mediawiki/extensions
    2. mkdir RDFIO
    3. cd RDFIO
    4. svn checkout .
    5. sudo nano /var/lib/mediawiki/LocalSettings.php
      1. and add the RDFIO blob given on Samuel's Install page
  4. install ARC2
    1. cd /usr/local/lib/mediawiki/extensions/SemanticMediaWiki/libs
    2. wget
    3. tar zxvf arc.tar.gz
  5. install the RDFIO pages onto the main page for easy access, add:
    1. [[Special:ARC2Admin|ARC2Admin]]
    2. [[Special:RDFImport|RDFImport]]
    3. [[Special:SPARQLEndpoint|SPARQLEndpoint]]
That's it. Not quite the 5 minutes that Samuel promised me, but I'm happy to have this available for my conference tour next month! I installed the default RDF, and got the nice default wiki page to which I can now start adding manual annotation:

If you are wondering about the use case, this RDF import is ideal for building up knowledge bases, as detailed in my Critical mass for Open Notebook Science wikis by prepopulation with RDF data post last month. Just aggregate the info on the web you can find (yes, that's another story), put it in your wiki and complement it with your local knowledge, import into Bioclipse, and run your analyses to verify your hypotheses!

Thanx to Samuel for this really great work!


  1. Nice writeup! :) So, you got it working with mediawiki in the Ubuntu repositories? That is nice!

    I seemed to run into troubles with MediaWiki 1.15 though :/ ... so I finally went for the latest bleeding edge (which is quite much what they use on wikipedia anyway, so tends to be quite stable most of the times).

  2. I am hoping that more people will give it a try...

    Where can feature requests and bugs be posted?

  3. Ah, yes, I'd suggest the Google code issue tracker for the moment:
    (I realize I should link it more frequently).

  4. Hi Egon, We are working on a new semantic wiki where we would like to enable some RDF import/export. However, we are running SMW 1.6 so I guess Saml's tool will not work just yet. As a first step, we would simply like to import one ontology (have owl and obo versions). It seems that the owl import feature is not present by default anymore? If you any pointers for working with owl in SMW, I'd appreciate hearing them.

  5. Hi Ben and Egon,

    FYI, I'm taking one week off from work to fix the RDFIO extension, starting today.

    I summarized the plans here:

    Regarding OWL import, RDFIO has not supported it so far. I have been thinking about including that in RDFIO sometime, but can't estimate when that will happen. Have to see how far I get this week first ...