Task Bus Routes
Total Page:16
File Type:pdf, Size:1020Kb
Task – Bus Routes
Consider an RDF document that contains information about bus companies and bus routes. A prefix named bus: identifies a given namespace (http://www.uia.no/ikt437/bus#). The data uses the following classes in the given namespace:
BusCompany represents bus companies; a bus company owns buses and operates bus routes.
BusStop represents bus stops along a bus route. A bus stop is a designated place where buses stop for passengers to board or leave a bus.
BusStation represents bus stations, which can be origin or target of bus routes. A bus station is a special kind of bus stop.
BusRoute represents bus routes. A route has an origin bus station (start bus station) and a target bus station (end bus station). We assume bus routes have unique labels (i.e., names). We also assume that routes are “one way routes”, e.g., if one route starts in Grimstad and ends in Oslo, a route going from Oslo to Grimstad must have another label (i.e., it is a different route).
The following properties are also used: rdfs:label links buss stations, bus stops, bus routes, etc., to their names bus:isOperatedBy links bus route to the bus company that operates it. bus:hasStartBusStation links a bus route to the bus station where the route starts. bus:hasEndBusStation links a bus route to the bus station where the route ends. a) Set up a Fuseki SPARQL endpoint and load the RDF Turtle statements given in the attachment below. b) Make and try a SPARQL query that lists all the bus routes (i.e., list the rdfs:labels of the bus routes) together with the bus company that operates it. c) Make a SPARQL query that lists all bus stops (i.e., list the rdfs:labels of the bus stops); avoid duplicates. Do not list bus stations. d) Make a SPARQL query that lists all bus stops (i.e., list the rdfs:labels of the bus stops) of the bus routes (i.e., a bus stop must be a stop on a bus route). List in alphabetic order and avoid duplicates. All bus stops should be listed except the one with rdfs:label "Fevik Bus Stop"^^xsd:string. Do not list bus stations. e) Make a SPARQL query that lists all the bus stops of bus route "Route 1 Kristiansand Arendal"^^xsd:string (this is the identifying label of the bus route) together with the bus company that operates it. The start and end bus stations should not be listed.
1 f) Make a SPARQL query that lists all the bus stops of bus route "Route 1 Kristiansand Arendal"^^xsd:string (this is the identifying label of the bus route) together with the bus company that operates it. List also start and end bus stations. “SPARQL provides a means of combining graph patterns so that one of several alternative graph patterns may match. If more than one of the alternatives matches, all the possible pattern solutions are found. Pattern alternatives are syntactically specified with the UNION keyword.”[1] Use the UNION construct when solving this task. g) You are to achieve the same as in the point above (… lists all the bus stops of bus route "Route 1 Kristiansand Arendal" …), but this time don’t use UNION but use arbitrary length path matching. “Connectivity between the subject and object by a property path of arbitrary length can be found using the "zero or more" property path operator, *, and the "one or more" property path operator, +.”[1] Hint: You need to add two rdfs:subPropertyOf to your ontology and then you use the * operator in your SPARQL statement. h) One and the same bus route can have several departures the same day; the number of departures and the departure times may vary from weekday to weekday. We simplify: We ignore public holidays, etc.; this means that there are only seven alternatives (one for each day of the week) for the daily scheduling of a bus route. We ignore rush hours. i.e., the time from one bus stop until the next is always the same. We handle time by just counting minutes since midnight. E.g., time 62 is two minutes past one in the night. (A bus route always stops on the same stops.)
The stored information can be used to: 1. Calculate the total time a route takes from start to end bus station. 2. Calculate the total time a route takes from a selected bus stop on a route to another bus station on the same route. 3. Show the time schedule for a route (i.e., time from stop to stop of a route) given a start time.
Use OWL and model the information needed (this should be an extension of the ontology shown in the Attachment). Insert an example of one or more routes. Make SPARQL statements that give the information stated in point 1, 2 and 3 above.
References
[1] SPARQL 1.1 Query Language, W3C Recommendation 21 March 2013. https://www.w3.org/TR/2013/REC-sparql11-query-20130321/
2 Attachment
@prefix bus:
# Object Properties bus:hasEndBusStation rdf:type owl:ObjectProperty . bus:isOperatedBy rdf:type owl:ObjectProperty ; rdfs:domain bus:BusRoute; rdfs:range bus:BusCompany. bus:hasStartBusStation rdf:type owl:ObjectProperty . bus:hasStopAtBusStop rdf:type owl:ObjectProperty .
# Classes bus:BusCompany rdf:type owl:Class . bus:BusRoute rdf:type owl:Class . bus:BusStation rdf:type owl:Class ; rdfs:subClassOf bus:BusStop . bus:BusStop rdf:type owl:Class .
# Individuals bus:AgderExpressen rdf:type bus:BusCompany , owl:NamedIndividual ; rdfs:label "Agder Expressen"^^xsd:string . bus:ArendalBusStation rdf:type bus:BusStation , owl:NamedIndividual ; rdfs:label "Arendal Bus Station"^^xsd:string . bus:FevikBusStop rdf:type bus:BusStop , owl:NamedIndividual ; rdfs:label "Fevik Bus Stop"^^xsd:string . bus:GrimstadBusStop rdf:type bus:BusStop , owl:NamedIndividual ; rdfs:label "Grimstad Bus Stop"^^xsd:string . bus:KristiansandBusStation rdf:type bus:BusStation , owl:NamedIndividual ; rdfs:label "Kristiansand Bus Station"^^xsd:string . bus:Route_191_Skien_Kristiansand rdf:type bus:BusRoute , owl:NamedIndividual ;
rdfs:label "Route 191 Skien Kristiansand"^^xsd:string ; bus:hasStopAtBusStop bus:FevikBusStop , bus:GrimstadBusStop ; bus:hasEndBusStation bus:KristiansandBusStation ; bus:hasStartBusStation bus:SkienBusStation ; bus:isOperatedBy bus:TelemarkExpressen .
3 bus:Route_1_Kristiansand_Arendal rdf:type bus:BusRoute , owl:NamedIndividual ; rdfs:label "Route 1 Kristiansand Arendal"^^xsd:string ; bus:isOperatedBy bus:AgderExpressen ; bus:hasEndBusStation bus:ArendalBusStation ; bus:hasStopAtBusStop bus:FevikBusStop , bus:GrimstadBusStop ; bus:hasStartBusStation bus:KristiansandBusStation . bus:Route_2_Arendal_Kristiansand rdf:type bus:BusRoute , owl:NamedIndividual ; rdfs:label "Route 2 Arendal Kristiansand"^^xsd:string ; bus:isOperatedBy bus:AgderExpressen ; bus:hasStartBusStation bus:ArendalBusStation ; bus:hasStopAtBusStop bus:GrimstadBusStop ; bus:hasEndBusStation bus:KristiansandBusStation . bus:SkienBusStation rdf:type bus:BusStation , owl:NamedIndividual ; rdfs:label "Skien Bus Station"^^xsd:string . bus:TelemarkExpressen rdf:type bus:BusCompany , owl:NamedIndividual ;
rdfs:label "Telemark Expressen"^^xsd:string .
4