Welcome to Semantic Web Tutorial

1. Introduction

This handout is meant as a guide for installing some of the tools that are needed for the tutorial.

Warnings

  • If you copy & paste from this document, make sure that the pasted
text is exactly the same as the copied one (sometimes quote marks are changed)
  • The only exception is when you see the text YOURUSERNAME: be sure
to replace it with your actual user name!
  • If you change any settings in Windows, you need to restart your
command prompt (CMD) for the changes to take effect

2. Important Stuff

A good programming editor, such as Atom, Sublime, TextMate (Mac only), Notepad++ (Windows only) or one of your own choice, is essential. It helps if it supports syntax highlighting for Turtle and/or SPARQL.

Make sure that you have Java, and your Java version is up to date.

Install JDK version 8u101 for your platform from:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Running java -version in your terminal/command prompt should give:

java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

A working version of Python, preferably somewhat close to 2.7.12 (but not 2.6 or 3.x) for your platform of choice.

  • Check what version you have by running python --version in a
terminal (or command prompt) window

NB: if you are an Anaconda user, and you’re happy with it (are you?), you should replace all occurrences of pip below with the corresponding conda command.

If needed:

  • Conda users can install Python 2.7 by running
conda install python=2.7 in the Terminal.
  • Windows users can go to https://www.python.org to download it. NB: make sure to enable the ‘Add Python.exe to path’ option during
installation.
  • Linux users should use the package manager of their
system (e.g. sudo apt-get install python)
  • MacOS comes with a

pre-installed version, but you may consider using Homebrew to install a clean and up-to-date version.

  • Start the Terminal application
  • Run

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" from the terminal - Then run brew update and brew doctor - Run brew install python

(For the lab session you may want to skip to section 3)

It is not usually a good idea to create and manipulate machine-interpretable files by hand. A good programming library for Linked Data is a real benefit.

Depending on your preferred programming language, examples are:

Simply pip install rdflib
JavaScript

3. The Protégé Ontology Editor

There are several RDF and OWL editors that you could use (apart from your favourite text-based editor). The main contenders are Protégé and TopBraid Composer.

We advise you to use Protégé for the assignments in Week 3.

  • Protégé is a stand-alone editor that is very much tailored
towards OWL ontology editing.
  • It allows you to define OWL axioms using an abstract syntax
(Manchester Syntax),
  • but it is less transparent if you’re interested in knowing what the
syntactic RDF representation looks like. This may lead to confusing situations where it is unclear e.g. in what namespace you have defined your classes, instances, etc.
  • Protégé does support all major OWL2 DL reasoners (Fact++, Hermit and
Pellet) and is thus quite powerful with respect to inferencing.
  • Download the the 5.0.0 version from GitHub:
  • Install the Pellet plugin from within Protege, but if that doesn’t
work...
  • Download the Pellet reasoner from

https://github.com/Complexible/pellet/archive/master.zip and place the com.clarkparsia.protege.plugin.pellet.jar file (from pellet/protege/plugin/) in the plugins directory of your Protégé installation.

  • On MacOS, you should right-click (ctrl-click) Protégé.app, and select “Show Package Contents”. You should put the Pellet jar file in the Contents/Java/plugins folder.
  • To run it:
  • The Windows installer should produce an icon for you, otherwise you
will need to run the run.bat (or similar) script in the Protégé directory.
  • On Linux, you should run the run.sh script in the Protégé
directory
  • On MacOS, you should run the Protégé.app application in the
Protégé directory
  • Make sure that the Pellet reasoner can be seen in the
Reasoner menu of the Protégé application window.

4 The Stardog triple store (version 4 or higher):

Stardog is a reasoning-enabled database for Linked Data and ontologies.

30-day evaluation)
  • You will receive an email with a link to the download, and a license
file.
  • NB: Stardog may require a Java JDK to be installed on your system
(not just a JRE, otherwise it will probably not work). Try getting it working without first installing Java. If it complains about it, install a recent JDK from Java.com

Official installation instructions can be found at http://docs.stardog.com/#_quick_start_guide

One way to get it running:

  • Move or copy the unzipped directory stardog-4.1.3 to your
Documents folder. You now have a directory called C:\Users\YOURUSERNAME\Documents\stardog-4.1.3 (where YOURUSERNAME is your actual user name!)
  • Create a data directory inside it, this is now
C:\Users\YOURUSERNAME\Documents\stardog-4.1.3\data
  • Copy the stardog-license.bin file to
C:\Users\YOURUSERNAME\Documents\stardog-4.1.3\data
  • Go to the Control Panel, and search for environment variables.
  • Create a system-wide variable called STARDOG_HOME and give it the value C:\Users\YOURUSERNAME\Documents\stardog-4.1.3\data.
  • Update the system-wide PATH variable by adding C:\Users\YOURUSERNAME\Documents\stardog-4.1.3\bin
  • Start the Command Prompt, and type
stardog-admin.bat server start --disable-security to start Stardog (you need to do this every time you have rebooted your system. If you want to manually stop the service, type stardog-admin.bat server stop)
are admin and admin
  • Whee!

Follow the next steps under 4.3

Alternative installation instructions can be found at http://docs.stardog.com/#_quick_start_guide

One way to get it running:

  • Move or copy the unzipped directory stardog-4.1.3 to your
Documents folder. You now have a directory called /Users/YOURUSERNAME/Documents/stardog-4.1.3
  • Create a data directory inside it, this is now
/Users/YOURUSERNAME/Documents/stardog-4.1.3/data
  • Copy the stardog-license.bin to
/Users/YOURUSERNAME/Documents/stardog-4.1.3/data
  • Open up a Terminal window, and type open ~/.bash_profile, this
opens a TextEdit window on mac. Linux users will know what to do.
  • Add the following lines anywhere in the file:
export STARDOG_HOME=/Users/YOURUSERNAME/Documents/stardog-4.1.3/data
export PATH=$PATH:/Users/YOURUSERNAME/Documents/stardog-4.1.3/bin
  • Close the Terminal window, and open a new one
  • Run the Stardog server via
stardog-admin server start --disable-security (you need to do this every time you have rebooted your system. If you want to manually stop the service, type stardog-admin server stop)
are admin and admin
  • Whee!

Follow the next steps under 4.3

To start: stardog-admin server start --disable-security (stardog-admin.bat on Windows)

To stop: stardog-admin server stop (stardog-admin.bat on Windows)

tutorial (you may need to login using admin/admin)
  • Make sure to set reasoning to SL and “SameAs reasoning” to
FULL otherwise leave the settings unchanged.
  • Done!

5. The Semantic Web Tutorial

Once you have Python, Java and Stardog in place, you can try out the Semantic Web tutorial.

  • Open up a Terminal or a Command Prompt window
  • Change directory to e.g. your Documents directory (on Mac/Linux:
cd ~/Documents, on Windows cd C:\Users\YOURUSERNAME\Documents)
  • If you have GIT, you can “clone” the source code from Github. Type:
git clone https://github.com/RinkeHoekstra/semanticweb-web-application-tutorial.git web-application to clone it into a folder called web-application
  • Otherwise, download the zip file from
  • Change directory to the newly created folder: cd web-application
  • (OPTIONAL) Setup the virtualenv in the directory of this
repository (virtualenv .)
  • (OPTIONAL) Activate the virtualenv (source bin/activate on
linux-like systems, or on windows Scripts\activate.bat)
  • Install the necessary packages (pip install -r requirements.txt)
  • Check the Stardog SPARQL endpoint URL in the TUTORIAL_REPOSITORY
variable in both src/tutorial.py and src/static/js/tutorial.js.
  • If you haven’t done so, install Stardog and make sure it is
running.
  • By default, the script assumes a Stardog database with the name
‘tutorial’ running at http://localhost:5820/tutorial.
  • The database should have
reasoning set toSLand "SameAs reasoning" toFULL. * Start your Stardog server withstardog-admin server start –disable-security``(don’t forget the``–disable-security``flag!). To stop Stardog, run``stardog-admin server stop. * If you want to use a different name or location (i.e. not running on localhost, port 5820) you need to set theTUTORIAL_REPOSITORYvariable insrc/tutorial.py`, and make appropriate modifications to the Stardog configuration.
  • Run the tutorial from within the src directory by running
python tutorial.py

Other information on how to run the tutorial can be found in the readme file on the GitHub page of the tutorial: https://github.com/RinkeHoekstra/semantic-web-application-tutorial.

Go to http://localhost:5000 in your browser.

  • In step 10,
  • type Aspirin, (this retrieves all matches for Aspirin from Linked
Life Data)
  • select the link Aspirin,
  • and press the “Link” button. This pushes the RDF representation of
LLD Aspirin to your Stardog instance.
  • Output should be ‘Ok!’
  • In step 11,
  • also type Aspirin (this will retrieve all matches for Aspirin
from DBPedia),
  • select the link Aspirin,
  • and press the “Link” button.
  • Output should be ‘Ok!’
  • In step 12,
  • just press the “Link” button.
  • Output should be ‘Ok!’
  • Skip step 13
  • In step 14,
  • just press the “Link” button.
  • Output should have two results, one from Linked Life Data, and one
from DBPedia.

Indices and tables