Test Case Title |
TC5.3 - Knowledge Base Semantic Search via SPARQL |
Goal |
Performing direction SPARQL queries searching for relationships among city entities, semantic search, modelled in the knowledge base as graph database à FLINT |
Prerequisites |
Using a PC or Mobile with a web browser. Knowledge about the RDF, OWL concepts. Knowledge about SPARQL. Access to ServiceMap, Knowledge base with data. Several of them are available with different number of data: (i) Florence and whole Tuscany, (ii) Helsinki, Antwerp and Bologna, (iii) Venezia, etc. The following functionalities are available only for specific Snap4city users with specific privileges. |
Expected successful result |
The possibility of visually inspecting the graph database structure of the knowledge base to understand the relationships among city entities. From the LOG tools it is possible to learn how to formalize SPARQL queries to search into the knowledge base. This approach may be used to extend the Smart City API, or to perform a direct access to the KB to get specific data and relationships, and to share experience with others users. For example, for implementing some data analytics for routing, traffic flow reconstruction, etc. Once learned the semantic queries in SPARQL can be tested using FLINT, the second tool. Please note that the disit.org">LOG.disit.org tool can be used discover Linked Open Data worldwide since a global index is provided. FLINT tool can be used as well on the many SPARQL repository listed in disit.org">LOG.disit.org. |
Steps |
Please note that some of the following links could be accessible only for registered users.
Example 1: Performing direction SPARQL queries searching for relationships among city entities, semantic search, modelled in the knowledge base as graph database à FLINT
- Go to snap4city portal
- Login as snap4city user (or any AreaManager or ToolAdmin user)
- Select in the Development tools menu the “Knowledge Base Queries” item
- It is a DISIT modified version of the Flint tool in which the engine for data licensing verification is also present.
- If you click on the button in the circle you just perform a SPARQL query on Km4City and the triples appear below as in the figure. If you click on the microbutton marked with the arrow, a window is open with some examples.
For example, the SPARQL query
SELECT * WHERE {
?s a km4c:Museum.
?s schema:name ?name.
?s schema:addressLocality "FIRENZE".
} ORDER BY ?name LIMIT 100
retrieves the name ordered list of all the musems of the city of Florence.
A slightly more complex query like:
SELECT * WHERE {
?s a km4c:Museum.
?s schema:name ?name.
?s schema:addressLocality "FIRENZE".
?s geo:geometry ?g1.
?x a km4c:Green_areas.
?x schema:name ?name2.
?x geo:geometry ?g2.
FILTER(bif:st_distance(?g1,?g2)<0.1)
} limit 10
Search for a florence museum with a green area within 100 meters.
- By clicking on the links returned (e.g. the ones in the “s” or “x” column) they can be explored using the LOG tool, in this way more relations can be explored and used to enhance the query. The following is an example: