Semantic web final assignment, We've used Sqvizler to build our own semantic web application. The application prototype was used to show the possibilites of finding all popular spots in the region of a university. The data which is used for this application comes from several datasources; respectively dbpedia.org, linkedgeodata.org and a local database with university information.
1. ‘My College Spot’
“The App for foreign students”
By: Selvi Ratnasingan
Barry Kollee
Group number: 41
Assignment: Final assignment
Course: Semantic Web
2.
Inhoud
Application and Knowledge Design ................................................................ 3
1. Description of our ontology. ................................................................... 3
2. Consider reusing existing ontologies. .................................................... 3
3. Enumerate important terms in the ontology. .......................................... 4
4. Define the classes and the class hierarchy. .......................................... 5
5. Define the classes and the class hierarchy. .......................................... 6
6. Define the properties of these properties. ............................................. 7
Integrating Information ................................................................................... 10
Get RDF from timesharing database .......................................................... 10
Data from external ontologies .................................................................... 10
DBPedia (for collecting information about universities) .......................... 11
LinkedGeoData ....................................................................................... 12
DBPedia (for collecting information about the spots) ............................. 13
RDF-files we used to query data ................................................................ 13
Application Interface ...................................................................................... 15
Appendixes .................................................................................................... 18
2
MY
COLLEGE
SPOT
3. Application and Knowledge Design
Firstly we designed our ontology according to the ontology building
methodology.
1. Description of our ontology.
The domain of our ontology is ‘Spot’s nearby Universities’. Our goal is to give users
of our application the opportunity to get information about all kinds of ‘spots’ nearby
universities. Examples of these sightseeing spots are museums, monuments and
restaurants.
Our first priority is to let our application support a distance measurer, where we
compare the geolocation (longitude & latitude) of the selected university and the
‘spot’ where the user refers to.
With the names of our ‘spot’ in mind we can get lots of information from the web
which gives information about our ‘spot’. We want to create a small pocket guide
which shows:
• Main info; give users insight in a description of the ‘spot’.
• Year; the year that the ‘spot’ has been created or built.
• Number of visitors; this will be the indicator of the popularity of the spot.
• Geolocation; this info is critical to compare the distance between the user’s
university and the actual ‘spot’.
Queries
To get all required information we need to perform several queries throughout the
web. Coupled to the information we need we can state that we need to perform the
following queries. These queries listed below should
• getSpotsNearbyUniversity:
o getGeoLocationOfUniversity:
o getGeoLocationOfSpot:
• getMainInfoOfSpot:
• getFoundingYearOfSpot:
• getNumberOfVisitors:
• getGeoLocationOfSpot:
2. Consider reusing existing ontologies.
To make an application which fullfills the requirements we need, we’ve chosen to
include the following ontologies:
• LinkedGeoData. This is the main ontology which we need because our first
priority is to compare the geolocation of the universtity with our ‘spot’. We
need to get the geolocation of the requested university and ‘spot’, the type of
‘spot’, and the names of the ‘spot’s’ nearby from geonames.org. We can
state that we need the following types:
o GeoMetry
o Longitude
o Latitude
o Name
• DBpedia. We want to use DBpedia to cover our small pocket guide. If we’re
able to retrieve all the names of the ‘spot’s’ we’ve requested we should be
MY
COLLEGE
SPOT
3
4. able to get some information about our ‘spot’s’ from DBpedia. The
information from DBpedia which we need are.
o Abstract (regular information about the ‘spot’)
o NumberOfVisitors
o FoundingYear
• We also make use of the university database which covers 200 Universities
throughout the world. This database is filled with names and ratings of
several universities. In our concept we are only interested in the name of the
university.
o NameOfUniversity
o Ratings
3. Enumerate important terms in the ontology.
We’ve thought of important terms throughout our brainstorm which should cover the
concept and goal we want to establish.
• Sightseeing
o Museums
o Monument
o Theater
o Zoo
o Park
o Restaurant
• University
• Location
o City
o Country
o Geolocation
• Departments
• Type Of spot
• To see, to eat, to relax
• International rating
• Number of Visitors
• Famous people
• Description of spot
• Founding year
• Cultural / non-Cultural
4
MY
COLLEGE
SPOT
5. 4. Define the classes and the class hierarchy.
With the terms of brainstorm session we started to define classes and then
we thought about the hierarchical relationship between classes. As you can
see we divided the spots into Cultural and Non-Cultural Spots.
MY
COLLEGE
SPOT
5
6. 5. Define the properties
After writing the properties for each classes we find out that some classes
have same literal properties like name, abstract, etc. So we defined one new
class for this common properties, BasicClass, as shown in the figure below.
In this diagram the data type properties are displayed under their own
classes. For example GeoLocation has latitude and longitude as data type
properties.
6
MY
COLLEGE
SPOT
7. 6. Define the properties of these properties.
In step 6 we define properties of defined properties and that means we add more
information to the properties. Besides of symmetric and inverse properties we
introduced in this step a restriction class which based on the property
“distanceBetween” . In this diagram the inverse properties are in red color and
symmetric properties are in blue.
MY
COLLEGE
SPOT
7
8. In the ontology we define the restriction class ‘NearbySpot’as follows:
rankings:NearbySpot
rdfs:subClassOf rankings:Spot ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty
rankings:distanceBetween ;
owl:hasValue
[ rdf:type rdfs:Datatype ;
owl:onDatatype xsd:float ;
owl:withRestriction (
[xsd:maxExclusive
"5"^^xsd:float]
)
]
] .
8
MY
COLLEGE
SPOT
9. After inferencing we get the following diagram of ontology. The green color shows
the equivalent class of the particular class and the equivalent properties are
displayed between the brackets.
For inferencing we followed the steps below:
• Syntax comparison (like searching for classes with same labels)
• Hierarchy comparison (like common parents of instances) (we pick one or
two instances of different countries and searching for common parents)
MY
COLLEGE
SPOT
9
10. Integrating Information
We now have a clear view on what our ontology should look like and we’re ready to
search for the components which we want to use in our application.
Get RDF from timesharing database
At first we started of with creating our own local database consisting of RDF. We’ve
used the timeshigher.sql file to build a mapping file. Within this mapping file we’ve
renamed the naming conventions of every subclass of the universities.
Because we’d like to perform queries to the DBpedia pages of the universities we’ve
adjusted a small part of the mapping file which is needed for the program D2RQ.
We wanted to have a direct useable URI object where we could query DBpedia with
directly. We’ve done this by adding the value uriPattern1 to the university it’s name.
For generating RDF dump of our database we’ve used the program D2RQ. This
program allows us to build the .ttl files which holds all information of timesharing
database what we need for our semantic web application. This .ttl file consists of an
N-Triple syntax. These dump files are necessary for us to perform queries to and
eventually to give the requested data we need.
Data from external ontologies
The most important information which we need is the ‘names’ of all the universities
which are listed in the timeshigher.sql file. We want to reuse the name of the
university to perform several queries to dbpedia.org and linkedgeodata.org.
Because of the complexity of our application we decided to copy the data from the
external ontologies as a dump file. For getting all the info we need we perform the
following queries:
11
d2rq:uriPattern
"http://dbpedia.org/resource/@@rankings.university|urlify@@";
10
MY
COLLEGE
SPOT
11. DBPedia (for collecting information about universities)
Get the DBPedia resources of all the universities which we request. To give
information about the university we perform queries for we use several properties
which are listed in the DBpedia pages for a university
• Abstract (main info about the requested university)
• City (place where the university is located)
• Country (country where the university is located)
• Image (image of the university)
• Latitude
• Longitude
prefix rankings: <http://www.example.org/vocab/>
construct {
?uni rankings:country
<http://dbpedia.org/resource/Netherlands> ;
rankings:city ?city ;
rankings:image ?image ;
rankings:abstract ?abstract;
rankings:long ?long ;
rankings:lat ?lat ;
rankings:name ?name .
}
WHERE {
?uni rdf:type
<http://dbpedia.org/ontology/EducationalInstitution> .
?uni <http://dbpedia.org/ontology/country>
<http://dbpedia.org/resource/Netherlands> .
?uni <http://dbpedia.org/property/city> ?city .
?uni <http://dbpedia.org/property/name> ?name .
?uni <http://dbpedia.org/ontology/thumbnail> ?image .
?uni <http://dbpedia.org/ontology/abstract> ?abstract .
?uni <http://www.w3.org/2003/01/geo/wgs84_pos#long> ?long .
?uni <http://www.w3.org/2003/01/geo/wgs84_pos#lat> ?lat .
FILTER(langMatches(lang(?name), "EN") &&
langMatches(lang(?abstract), "EN") )
In this query as you see we get only information of the universities in The
Netherlands, because of memory issues we decided to scope our application only
in The Netherlands.
MY
COLLEGE
SPOT
11
12. LinkedGeoData
We use linkedgeodata to check if a certain spot is within a particular range of the
university. With the query listed below we want to receive the following information of
all the retrieved results.
• Longitude (is a part of the geolocation)
• Latitude (is a part of the geolocation)
• Name of the spot.
The following query is utilized to compare the geolocation of university and spots to
get all tourist spots within a radius of 5 km.
Prefix lgd: <http://linkedgeodata.org/>
Prefix lgdo: http://linkedgeodata.org/ontology/
Select ?spot ?name ?spotgeo
from <http://linkedgeodata.org> {
?uni owl:sameAs
<http://dbpedia.org/resource/University_of_Amsterdam> .
?uni geo:geometry ?unigeo .
?spot a lgdo:Tourism .
OPTIONAL { ?spot rdfs:label ?name . }
?spot geo:geometry ?spotgeo .
Filter(bif:st_intersects(?unigeo, ?spotgeo, 5))
}
In this query we are giving in two inputs.
• Type of spot (i.e. Tourism, Theatre, SportsCentre, Monument and others)
• DBpedia resource of the spot where we should compare with
In our demo application we’ve only used the University of Amsterdam as the
DBPedia input.
12
MY
COLLEGE
SPOT
13. DBPedia (for collecting information about the spots)
With the above information we are already able to give a map view of all the
universities inside the timeshigher.sql file and the spots where we want to refer to.
To give a more broader view on all the ‘spots’ nearby the university we want to
perform some queries to DBpedia.org. We do this for retrieving the info of all the
spots nearby the requested university. The info which we want to retrieve is:
• Name (The name of the requested spot)
• Abstract (a small description of the spot)
• Image (image of the spot)
• Founding year (for some spots we want to give info about the founding year,
i.e. monuments)
• Number of visitors (for some spots we want to give an indicator of it’s
popularity. We do this with the number of visitors)
• Year completed (for some spots we want to show the completion year (i.e. a
church)).
• Resting place of, (in some cases we want to show the persons resting place
of a spot. (i.e. Gaudi of the ‘Sagrada Familia’ in Barcelona)
Within this querie we request for main info about the requested spot. This spot is
retrieved via the geolocation comparison query. In the example listed below *name*
is the name of the requested spot. The implementation of the data of this spot isn’t
implemented inside the demo application. But we can state that we would be able
to implement this pretty easily and reuse the data which is generated by this query.
CONSTRUCT {
<http://dbpedia.org/resource/*name*> ?p ?o .
?s ?p2 <http://dbpedia.org/resource/*name*>.
}
WHERE {
{ <http://dbpedia.org/resource/*name*> ?p ?o }
UNION {
?s ?p2 <http://dbpedia.org/resource/*name*> }
}
MY
COLLEGE
SPOT
13
14. RDF-files we used to query data
• Our own ontology. In this file we define the class Ranking. This has 2
properties which we use in our web application. These two properties which
we want to reuse in our
application.
o The name of the
university
o The rank of the
university
• The university data, within
this file all the info from the
timeshigher database is
listed. In here we also
define our direct URL to
the DBpedia page from
the actual university.
• Individual information of
every university. This file
holds all the information
which we need from every
single university for our application. The content of this a dump file is from
DBpedia.org.
• Location based information about the university and the spots nearby. We
want to know what the exact geolocation is of the requested university. We
also need to reuse this longitude and latitude to get some spots. We are
interested in the geolocation of the universities and spots and the names of
the spots. This information should be retrieved from linkedgeodata.org and
geonames.org.
• Information about spots. We want to give some information (abstract) about
the spots and the properties which are listed in our own ontology (i.e.
numberOfVisitors). This information is being retrieved from DBpedia
To finish up our setup and to get information about the spots and the universities we
needed to setup a SPARQL server which enables us to perform queries on our
localhost. For retrieving our final goal we’ve configured Joseki2. We place all the
created dump files into Joseki together with our own ontology (the university list)
and Joseki has been configured completely.
2
http://www.joseki.org/
14
MY
COLLEGE
SPOT
15. Application Interface
With Joseki installed and our RDF files in place we’re ready to go to perform our
SPARQL queries to all our dump files we created. Within our localhost we use
SPARQLer to give us the results on certain requests we make. These requests will
be used later on within the top layer of our application. The results of these requests
will be displayed later on within the web browse. The actual result of our website
and the html code which we used can be found in the appendix.
List of queries which we used to display the information on our webpage:
Query 1: Get a particular University from the timeshigher database based on
it’s rank and give regular info about this university
PREFIX rankings: <http://www.example.org/vocab/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
prefix dbpedia: <http://dbpedia.org/ontology/#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?Name ?Abstract ?Rank
WHERE{
?uni rankings:idOfRanking '92'^^xsd:integer .
?uni rankings:orderOfRanking ?Rank .
?uni rankings:belongsTo ?link .
?link rankings:name ?Name .
?link rankings:abstract ?Abstract .
}
LIMIT 10
Query 2: Get the name and location of the university based on it’s idOfRanking
PREFIX rankings: <http://www.example.org/vocab/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
prefix dbpedia: <http://dbpedia.org/ontology/#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?lat ?long ?name ?uni
WHERE{
?uni rankings:idOfRanking '92'^^xsd:integer .
?uni rankings:belongsTo ?link .
?link rankings:name ?name .
?link rankings:lat ?lat .
?link rankings:long ?long .
}
MY
COLLEGE
SPOT
15
16.
Query 3: Compare the geolocation of the university and spots nearby and get
all the tourist spots within a radius of 5 km.
PREFIX rankings: <http://www.example.org/vocab/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
prefix dbpedia: <http://dbpedia.org/ontology/#>
prefix owl: <http://www.w3.org/2002/07/owl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?Touristspot
WHERE{
?uni rankings:idOfRanking '92'^^xsd:integer .
?uni rankings:belongsTo ?link .
?link rankings:name ?name .
?link rankings:abstract ?abstract .
?spot rankings:isNearBy ?link .
?spot rankings:name ?Touristspot .
?spot rankings:hasGeo ?spotGeo .
}
16
MY
COLLEGE
SPOT
17. The demo setup
To use our application in an online
environment where we can
display the content to the user we
need to be able to host our
application and give it a front end.
We do this by using the tool
SGVizler. We imported the given
queries within our .html code for
displaying our data within
components which are available
within SGVizler. Both the source
code and the screenshots of our
final demo application can be
found in the Appendixes.
MY
COLLEGE
SPOT
17
22. rankings:Restaurant a rdfs:Class; rdfs:subClassOf rankings:Non-
cultural_Spot .
rankings:Theater a rdfs:Class; rdfs:subClassOf rankings:Non-
cultural_Spot .
rankings:Church a rdfs:Class; rdfs:subClassOf rankings:Cultural_Spot .
rankings:Monument a rdfs:Class; rdfs:subClassOf
rankings:Cultural_Spot .
rankings:Museum a rdfs:Class; rdfs:subClassOf rankings:Cultural_Spot .
rankings:Art a rdfs:Class; rdfs:subClassOf rankings:BasicClass .
rankings:has a rdfs:Property;
rdfs:domain rankings:Museum; rdfs:range
rankings:Art .
rankings:has owl:equivalentProperty dbp-prop:museum .
rankings:isPlacedIn a rdfs:Property;
rdfs:domain rankings:Art; rdfs:range
rankings:Museum .
rankings:has owl:inverseOf rankings:isPlacedIn .
rankings:Person a rdfs:Class; rdfs:subClassOf rankings:BasicClass .
rankings:Person owl:equivalentClass dbp-owl:Person .
rankings:birthDate a rdfs:Property;
rdfs:domain rankings:Person; rdfs:range xsd:date .
rankings:birthDate owl:equivalentProperty dbp-owl:birthDate .
rankings:deathDate a rdfs:Property;
rdfs:domain rankings:Person; rdfs:range xsd:date .
rankings:deathDate owl:equivalentProperty dbp-owl:deathDate .
rankings:createdBy a rdfs:Property;
rdfs:domain rankings:Art; rdfs:range
rankings:Person .
rankings:createdBy owl:equivalentProperty dbp-prop:artist .
rankings:created a rdfs:Property;
rdfs:domain rankings:Person; rdfs:range
rankings:Art .
rankings:createdBy owl:inverseOf rankings:created .
22
MY
COLLEGE
SPOT
23. Appendix 3: Snippet of the Education information dump file
@prefix ns0: <http://www.example.org/vocab/> .
@prefix dbpedia: <http://dbpedia.org/resource/> .
dbpedia:Eindhoven_University_of_Technology ns0:name "Eindhoven University of
Technology"@en ;
ns0:city dbpedia:Eindhoven .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
dbpedia:Eindhoven_University_of_Technology ns0:lat "51.4481"^^xsd:float ;
ns0:abstract "The Eindhoven University of Technology is a university of
technology located in Eindhoven, Netherlands. The motto of the university is: Mens
agitat molem (The mind brings matter into motion). The university was the second of
its kind in the Netherlands, only Delft University of Technology existed previously.
Until mid-1980 it was known as the Technische Hogeschool Eindhoven (abbr. THE). In
2011 QS World University Rankings placed Eindhoven at 146th internationally, but 61st
globally for Engineering & IT. Furthermore, in 2011 Academic Ranking of World
Universities (ARWU) rankings, TU/e was placed at the 52-75 bucket internationally in
Engineering/Technology and Computer Science (ENG) category and at 34th place
internationally in the Computer Science subject field."@en ;
ns0:long "5.48972"^^xsd:float ;
ns0:image
<http://upload.wikimedia.org/wikipedia/commons/thumb/5/51/TU_Eindhoven.jpg/200
px-TU_Eindhoven.jpg> ;
ns0:country dbpedia:Netherlands .
dbpedia:University_of_Twente ns0:name "University of Twente"@en ;
ns0:city dbpedia:Enschede ;
ns0:lat "52.2427"^^xsd:float ;
ns0:abstract "University of Twente is a university located in Enschede,
Netherlands. It offers research and degree programmes in the social and behavioral
sciences and in engineering. In keeping with its entrepreneurial spirit, the
University is committed to making economic and social contribution to the region of
the Netherlands where it is based. The UT collaborates with Delft University of
Technology and Eindhoven University of Technology under the umbrella of the 3TU.
Federation, and is also a partner in the European Consortium of Innovative
Universities (ECIU)."@en ;
ns0:long "6.85326"^^xsd:float ;
ns0:image
<http://upload.wikimedia.org/wikipedia/commons/thumb/4/43/University_of_Twente
_logo_-_english_version.png/200px-University_of_Twente_logo_-_english_version.png> ;
ns0:country dbpedia:Netherlands .
MY
COLLEGE
SPOT
23
25. Appendix 5: Screenshots of our application
Overal view with information about the University of Amsterdam , it’s location
on the map, the spots that are nearby and these spots within a mapview.
Main info about the university of Amsterdam
MY
COLLEGE
SPOT
25
26. Selection of the spots nearby the University of Amsterdam
Mapview of the spots nearby the university of Amsterdam
26
MY
COLLEGE
SPOT
27. Appendix 6: Source code of our webpage (SGVizler)
<!DOCTYPE HTML>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sgvizler</title>
<meta charset="UTF-8"/>
<link rel="shortcut icon"
href="http://sgvizler.googlecode.com/svn/www/favicon.ico" />
<link rel="stylesheet" type="text/css"
href="http://sgvizler.googlecode.com/svn/www/sgvizler.css" />
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" id="sgvzlr_script"
src="http://sgvizler.googlecode.com/svn/release/0.4/sgvizler.js"></script>
<script type="text/javascript">
// CONFIGURATION Sgvizler 0.4: Set variables to fit your setup.
// NB! Do not let the last item in a list end with a comma.
//// Query settings. The defaults settings are listed.
sgvizler.queryOptions = {
// Default query.
//'query': "SELECT ?class (count(?instance)
AS ?noOfInstances)nWHERE{ ?instance a ?class }nGROUP BY ?classnORDER BY ?class",
// Endpoint URL.
'endpoint': "http://localhost:2020/sparql",
// Endpoint output format.
'endpoint_output': 'json', // 'xml' or 'json'
// This string is appended the 'endpoint' variable and the query to it
again to give a link to the "raw" query results.
'endpoint_query_url': "?output=text&query=",
// URL to SPARQL validation service. The query is appended to it.
//'validator_query_url': "http://www.sparql.org/query-
validator?languageSyntax=SPARQL&outputFormat=sparql&linenumbers=true&query
=",
// Default chart type.
//'chart': 'gLineChart'
// Default log level. Must be either 0, 1, or 2.
'loglevel': 2
};
//// Prefixes
// Add convenient prefixes for your dataset. rdf, rdfs, xsd, owl
// are already set. Examples:
sgvizler.namespaces['wd'] = 'http://sws.ifi.uio.no/d2rq/resource/';
sgvizler.namespaces['w'] = 'http://sws.ifi.uio.no/ont/world.owl#';
//// Your chart drawing preferences. The defaults are listed.
// See the Google visualization API for available options for
// Google charts, and the Sgvizler homepage for other
// options. Options applicable to all charts are put in the
// "root" of sgvizler.chartOptions. Chart specific options are
// put in a "child" with the chart's id as name,
// e.g. 'gGeoMap'.
sgvizler.chartOptions = {
//'width': '800',
//'height': '400',
//'chartArea': { left: '5%', top: '5%', width: '75%', height: '80%' },
// 'gGeoMap': {
// 'dataMode': 'markers'
// },
// 'gMap': {
// 'dataMode': 'markers',
// },
// 'sMap': {
// 'dataMode': 'markers',
// 'showTip': true,
// 'useMapTypeControl': true
// }
MY
COLLEGE
SPOT
27