Automating an RDF ontology import into Semantic Mediawiki
Semantic Mediawiki(SMW) allows external ontologies to be imported into a Mediawiki (MW) instance. External ontology's properties and classes can be used inside the MW instance, and produce a RDF exports of the wiki pages, which point to IRIs of the imported ontology(s).
The process of importing is simple, but time consuming. Hence making it a perfect candidate for an automated process, which can be run at anytime a new version of the ontology is published, hence this python script.
Watch the ontology2smw presentation at SMWCon 2020.
Supports:
git clone https://github.com/TIBHannover/ontology2smw.git
cd ontology2smw
# ---- (optional) create and activate a virtual-environment
python -m venv venv
source venv/bin/activate
# ---- virtual environment created
pip install --upgrade setuptools
python setup.py install
Run:
Using a remote ontology:ontology2smw --format ttl --ontology https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl
Writing to wiki pages:ontology2smw --format ttl --ontology https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl --write
Asking for help:ontology2smw --help
usage: ontology2smw [-h] [-w] [-o ONTOLOGY] [-f {rdf,ttl}] [-v] [-r]
___
{ . . }
--------------o00---'----00o--
ontology2SMW
-----------------------------
optional arguments:
-h, --help show this help message and exit
-w, --write writes the output to wiki or file. Default: False (dry-run).
-o ONTOLOGY, --ontology ONTOLOGY
Ontology file or URI. Default: https://raw.githubusercontent.com/tibonto/aeon/master/aeon.ttl
-f {rdf,ttl}, --format {rdf,ttl}
Ontology format. Default value: ttl
-v, --verbose Verbose output. Default: False.
-r, --report Save report in file report.txt Default: False.
wikidetails.yml & wiki write access
Special:UserRights
Special:BotPasswords
wikidetails.template.yml
as wikidetails.yml
and fill in bot name and password:The local test VM, mentioned in the following section, sets a bot account for
the Admin user, so that once the VM is created you can just run the script against it.
Details for that wiki, VM, bot username and password are set in wikidetails.yml
In order to test ontology2smw in action in a isolated virtual environment, the repository includes a Ansible playbook which creates a VM with Mediawiki installed, and also creates a Bot account for wiki user Admin.
The playbook sets Mediawiki with:
Requirements:
Create VM:
cd vm
vagrant up
ansible-playbook playbook_mw.yml
Once tests are done you can either,
vagrant suspend
so it can be reused from the state it was left in with vagrant up
vagrant destroy
git clone https://github.com/TIBHannover/ontology2smw.git
cd ontology2smw
# (optional) create and activate a virtual-environment
pip install -r requirements.txt
python -m ontology2smw
Tox: automated testing on py36, py37, py38
tox -p all -v
pytest
pytest -m "not smw"
pytest
for all the tests