Advanced knowledge exploration (cpp)

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.

std::vector<std::vector<std::string> > findRoutes(const std::string& path_from, const std::string& path_to, const std::string& selector)
std::vector<std::string> paths = onto_->individuals.getOn(intersection, "isAlong", selector);
std::vector<std::string> find(const std::string& from, const std::string& to, const std::string& selector)
std::vector<std::string> paths_from = onto_->individuals.getOn(from, "isAlong", selector);
std::vector<std::string> paths_to = onto_->individuals.getFrom("hasAlong", to, selector);
std::vector<std::vector<std::string> > routes = findRoutes(path_from, path_to, selector);
std::vector<std::string> route;

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 ...

Compile and launch the program. You should have the following result:

road_2 - int_7 - pp_4 - int_12 - road_3 -
road_3 - int_11 - pp_3 - int_10 - road_4 -
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.