Thursday, 15 October 2015

Example of using SWRL built-ins with Solar System ontology.

Introduction to SWRL


Semantic Web Rule Language (SWRL for short) is a combination of OWL DL and OWL Lite sub-languages of OWL Web Ontology. It is possible to write ontology with SWRL built-ins in Ontorion Fluent Editor. One of such example of ontology written by using Semantic Web Rule Language is Cognitum's Solar System Ontology.

To follow along open Fluent Editor, go to File -> New and type Solar System. Double click on the template to open.







Introduction to Solar System ontology



Here is the core of our solar system ontology.
In the picture above it is seen that every instance in our ontology that orbits something is either a planet or a moon. Planets orbit some stars and moons orbit some planets. Later it can be possible to ask very complex queries with Fluent Editor with these two simple rules. Then later in the ontology data modelling is utilized. 

We define relations such as:
  • has-index
  • orbits
  • has-semimajor-axis-1000-km
  • has-period
  • was-discovered-by
  • was-discovered-in-year
And with these relations assigned to each instance we can later ask very complex queries.





How does rule written in SWRL look like?



You describe concepts/instances as a thing and attributes as a value. If you want to reference previous stated instance/concept use the thing and while referencing previous stated attribute use the value
Fluent Editor supports core SWRL built-ins such as: comparisons, maths, strings, date, time and duration. In the example above it can be seen that comparison operator is used.
Rule above states which radius of orbiting of a star is higher. For instance let's ask the materialized graph (reasoner HermiT does not support SWRL yet) following query.

Who-or-What is covered by Earth?




It got us this response and indeed, it is true. Venus and Mercury are closer to the Sun than the Earth.
Now let's ask about orbiting radius of Mars.

Who-or-What is covered by Mars?




And once again it can be seen that our ontology, thus SWRL is working correctly. Not only the Venus and Mercury is included but also the Earth.

Other types of query

It is possible to directly make SPARQL queries.

SELECT ?y WHERE {:Mars :covers ?y}



Or use SWRL Debugger in Tools tab.





Complex queries

Try following query:

Who-or-What was-discovered-in-year greater-than 1900 and is a planet and covers Neptune?



While debate about Pluto being a planet is still up to date Fluent Editor, will provide an answer regardless of others people opinion. 

Not only we had built SWRL feature into Fluent Editor but also we expanded it. We implemented SOUNDEX algorithm into semantics of Fluent Editor. Check example below.



SOUNDEX algorithm allows us to approximate and compare words which have similar pronunciation. For instance, ask following query:


It responded with all moons which were discovered by a person with approximately the same name.
In this case - identical.

Summary


Fluent Editor provides necessary tools to write simple and quite complex rules using SWRL built-ins. You can easily query the materialized graph, or use SPARQL queries directly to achieve response you expect.

More Resources:

2 comments:

  1. How does one say in Fluent CNL, "if a thing has-end-date equal-to value(1) and the thing has-start-date equal-to value(2) then the value(2) must be greater-than-or-equal-to the value(1)" ?

    ReplyDelete
  2. SWRL as a proposed language for the semantic web as I am using for programming for logic etc... is a huge help for the simulations I'm currently on. Thanks for the tips btw, if you happen to know some writing services, would you mind recommending one too. This Edusson reviews has too many promises but failed to even deliver one.

    ReplyDelete