Source code for module.utils.set_relationships

import avesterra as av


[docs] def set_relationships(person_entity: av.AvEntity, company_entity: av.AvEntity, auth: av.AvAuthorization): """ The lesson on setting person facts (see :meth:`module.utils.set_person_facts`) demonstrated adding a company string to the person entity to denote the company the person is an employee of. However, this is quite limiting because there is no context provided by the company string. Where is the company located, what's the average salary of the company, what's the ratio of job categories of the company? The power of Orchestra is in modeling real world entities that can be joined together as a relationship. This code snippet shows how to relate the person entity with the company entity to show how to join 2 entities together to startt to form a knowledge graph. :param person_entity: The entity ID of the person entity to add the company relationship. :param company_entity: The entity ID of the company entity to relate to the person entity. :param auth: The Orchestra server authorization that allows entity operations. """ av.set_fact( entity=person_entity, attribute=av.AvAttribute.COMPANY, value=av.AvValue.encode_entity(company_entity), # here we set the entity ID instead of a string. authorization=auth, ) av.set_fact( entity=company_entity, attribute=av.AvAttribute.EMPLOYEE, value=av.AvValue.encode_entity(person_entity), # here we set the entity ID instead of a string. authorization=auth, )