Advanced knowledge exploration (python)

How to go home ?

Better understand our environment

Bob arrives well at home but he rolls on the pedestrian paths with his car ...

To settle this, we could use inheritance seen in the previous tutorial to check the type of path but you must already imagine the complexity that it will generate.

Instead of doing this, we will use the third parameter of the getOn and getFrom functions which is in fact optional. This third parameter is what we will call a selector. If it is set, the functions will only return the individuals inheriting the selector.

def findRoutes(path_from, path_to, selector):
paths = _onto.individuals.getOn(intersection, 'isAlong', selector)
def find(place_from, place_to, selector):
paths_from = _onto.individuals.getOn(place_from, 'isAlong', selector)
paths_to = _onto.individuals.getFrom('hasAlong', place_to, selector)
routes = findRoutes(path_from, path_to, selector)
route = find('pub', 'house', 'path')
displayRoute(route)

route = find('house', 'car', 'path')
displayRoute(route)

route = find('car', 'house', 'road')
displayRoute(route)

Well, we have already finished. It would be almost too simple ...

Launch the program. You should have the following result:

Route:
- road_2
- int_7
- pp_4
- int_12
- road_3
Route:
- road_3
- int_11
- pp_3
- int_10
- road_4
Route:
- road_4
- int_5
- road_2
- int_6
- road_5
- int_3
- road_1
- int_4
- road_6
- int_13
- road_3

This time it's good, Bob stopped driving on pedestrian paths.

Go further

We have seen here that properties are applied to individuals but properties can also be applied to the general concepts of classes. Moreover, we have only seen two properties exploration functions while there are many more. To go further, I advise you to go take a look at the documentation of the API that presents all of these functions: IndividualClient and ClassClient.