simphony-osp icon indicating copy to clipboard operation
simphony-osp copied to clipboard

Introducing the connect method

Open yoavnash opened this issue 5 years ago • 6 comments

The add implies an active containment relationship, even though that might not be the case.

Example 1 - adding with a passive relationship:

car = my_onto.car()
engine = my_onto.engine()
car.add(engine, rel=my_onto.is_part_of) # is_part_of is a passive relationship

Problem: is_part_of is a passive relationship, therefore it is the car that is added to the engine, and not the other way around, as the user intended.

Example 2 - adding with a non-containment relationship:

alice = my_onto.person(name="Alice")
bob = my_onto.person(name="Bob")
alice.add(bob, rel=my_onto.friends_with) # friends_with is a non-containment (and symmetrical) relationship

Problem: Bob is not contained by Alice, although the user added Bob to Alice.

Proposed solution

Add a new method to the API called connect, while keeping the add method but making it throw an exception whenever a non-active relationship is used. This allows the API to be more general while reducing confusion and detecting errors.

yoavnash avatar Jul 09 '20 08:07 yoavnash

Thank you @yoavnash for summarizing the latest discussions we had on mattermost. Here are a couple of comments ttat would be helpful as a background to this issue:

  1. the engine should be added to the car in example 1, why is it different?
  2. in EMMO, Bob would belong (be member of) the set of friends to Alice. Here we want to have a way to support - at least practically or temporarily - non EMMO compliant ontology, i.e., one that is not mereotopological in nature. the connect is then a bypass for creating the sets of friends like in the example above.

ahashibon avatar Jul 09 '20 08:07 ahashibon

Regarding the first list item: the user wants to add the engine to the car, but what happens in fact is that the car is added to the engine (!), which is obviously not was the intent.

yoavnash avatar Jul 09 '20 09:07 yoavnash

you mean we add the reverse relation, the engine knows about the car, but the car does not know about the engine?

ahashibon avatar Jul 09 '20 09:07 ahashibon

Not exactly. They both know about each other, but it is the case the engine contains the car, and not the other way around.

yoavnash avatar Jul 09 '20 09:07 yoavnash

When a cuds object is added, OSP-core adds the opposite relationship (either the passive or the active) in the other direction.

pablo-de-andres avatar Jul 09 '20 09:07 pablo-de-andres

One more thought: We have the remove method that removes the relationship with another object. Similarly we have the add methods, that adds a relationship to another object. Therefore, it makes sense how it is.

In this interpretation add means adding a relationship and not adding to a container.

urbanmatthias avatar Aug 04 '20 13:08 urbanmatthias