Merging two individuals

classic Classic list List threaded Threaded
3 messages Options
ehe
Reply | Threaded
Open this post in threaded view
|

Merging two individuals

ehe
Hi, I would like to merge two individuals so that all associated properties are merged into one instance. In Protege this can be done by simply giving the second individual the same name as the first (change iri). Since owlready2 is based on a sql lite database, this approach throws an error:

a1.set_iri(a2.iri)

>> sqlite3.IntegrityError: UNIQUE constraint failed: resource.iri

Is there another way to perform a merging without transferring all properties, class assertions and annotations individually?

Reply | Threaded
Open this post in threaded view
|

Re: Merging two individuals

Jiba
Administrator
Hi,

Unfortunately, there is no other way than transferring all properties, class assertions and annotations manually, or copying them directly in the database (but it will not update the Python object).

I could implement the copy of the properties, class assertions and annotations in set_iri(), but the problem is that I cannot merge the 2 Python objects representing the individuals (since Python has no method for merging two distinct objects).

Jiba
ehe
Reply | Threaded
Open this post in threaded view
|

Re: Merging two individuals

ehe
Hi,

The copy functions would help me a little. For merging you could override the __add__ method of the Thing class to allow the following operation:

individual 1 = individual1 + individual2