PatternsSubscriber Class
The PatternsSubscriber class provides an abstraction ontologenius subscription mechanism.More...
Ros1 Package: | ontologenius |
Ros2 Package: | ontopy |
Methods
__init__(self, name) | |
int | subscribe(self, pattern, callback, count = -1) |
bool | cancel(self, id) |
bool | end(self, dest_name, src_name) |
Detailed Description
The PatternsSubscriber class provides an abstraction ontologenius subscription mechanism.
Querying a knowledge base is interesting but when one is waiting a given fact, pulling the knowledge base can be an issue. To solve that, Ontologenius provide a subscription mechanism allowing to subscribe not one only to given facts but also to patterns.
Methods Documentation
__init__(self, name)
Constructs a pattern subscriber.
Can be used in a multi-ontology mode by specifying the name of the ontology name(str). For classic use, name(str) should be defined as "".
subscribe(self, pattern, callback, count)
Subscribes to a given pattern(str) linked to a callback(function(str)). Patterns are in the form "[add]subject|property|object". Subject and object can be set as classes such as "[add]Cube|isOnTopOf|Table" to subscibe to any fact representing a cube being on a table. In addition, any of the four elements can be setted with question mark which can be read as "any". For example, "[?]?isOnTopOf|Table" to subscribe to any deletion or addition of any thing being on a entity of type Table.
The parameter count(int) can be set to limit the subscription. Default parameter -1 corresponds to an unlimited subscription.
This function returns the subscription id(int). This later is only used to manually unsubscribe.
cancel(self, id)
Manualy unsubscribe from a pattern using the corresponding subscription
Return True if the unsubscription suceeded.
end(self)
Tests if any subscription is still ongoing.