def model_authorship_group(self, record, data): if not data: return record.setdefault('_people', []) record.setdefault('created_by', []) authors = _as_list(data.get('primary_author')) mlap = MakeLinkedArtPerson() mlao = MakeLinkedArtOrganization() ordered_data = [] article_label = record['label'] creation_id = record['uri'] + '-Creation' creation = model.Creation(ident=creation_id, label=f'Creation of {article_label}') for a in authors: gaia_id = a['gaia_authority_id'] gaia_type = a['gaia_authority_type'] name = a['author_name'] roles = _as_list(a['author_role']) order = a['author_order'] ordered_data.append((order, name)) p = { 'label': name, 'name': name, } if gaia_type == 'Person': uri = self.helper.person_uri(gaia_id) p['uri'] = uri mlap(p) elif gaia_type == 'Corp': uri = self.helper.corporate_body_uri(gaia_id) p['uri'] = uri mlao(p) else: raise Exception( f'Unexpected type of authorship record: {gaia_type}') # uri = self.helper.make_proj_uri(gaia_type, 'GAIA', gaia_id) record['_people'].append(p) for role in roles: part = model.Creation(ident='', label=f'{role} Creation sub-event') part.carried_out_by = get_crom_object(p) cl = self.helper.role_type(role) if cl: part.classified_as = cl creation.part = part ordered_authors = [p[1] for p in sorted(ordered_data)] order_string = self.helper.ordered_author_string(ordered_authors) creation.referred_to_by = vocab.Note(ident='', content=order_string) record['created_by'].append(creation)
def __call__(self, data: dict, non_auctions): '''Add modeling for the entry describing a physical auction catalog in the PSCP dataset.''' cno = data['catalog_number'] owner = data['owner_code'] copy = data['copy_number'] rec_num = data['star_record_no'] sale_type = non_auctions.get(cno, data.get('non_auction_flag', 'Auction')) keys = [v for v in [cno, owner, copy] if v] record_uri = self.helper.make_proj_uri('ENTRY', 'PHYS-CAT', *keys) content = data['star_csv_data'] catalog_label = self.helper.physical_catalog_label( cno, sale_type, owner, copy) row_name = f'STAR Entry for Physical {catalog_label}' row = vocab.EntryTextForm(ident=record_uri, content=content, label=row_name) row.part_of = self.helper.static_instances.get_instance( 'LinguisticObject', 'db-sales_catalogs') creation = model.Creation(ident='') creation.carried_out_by = self.helper.static_instances.get_instance( 'Group', 'gpi') row.created_by = creation row.identified_by = self.helper.gpi_number_id(rec_num, vocab.StarNumber) row.identified_by = vocab.PrimaryName(ident='', content=row_name) data['_catalog_record'] = add_crom_data({'uri': record_uri}, row) yield data
def add_aata_authors(data): ''' Given a `dict` representing an "article," extract the authorship records and their role (e.g. author, editor). yield a new `dict`s for each such creator (subsequently referred to as simply "author"). The resulting author `dict` will contain these keys: * `_aata_record_id`: The identifier of the corresponding article * `_aata_record_author_seq`: A integer identifying this author (unique within the scope of the article) * `label`: The name of the author * `creation_role`: The role the author played in the creation of the "article" (e.g. `'Author'`) * `names`: A `list` of names this organization may be identified by * `identifiers`: A `list` of (identifier, identifier type) pairs * `uid`: A unique ID for this organization * `parent`: The model object representing the corresponding article * `parent_data`: The `dict` representing the corresponding article * `events`: A `list` of `model.Creation` objects representing the part played by the author in the article's creation event. ''' lod_object = get_crom_object(data) event = model.Creation() lod_object.created_by = event authors = data.get('_authors', []) make_la_person = MakeLinkedArtPerson() for a in authors: make_la_person(a) person_name = a['label'] person = get_crom_object(a) subevent = model.Creation() # TODO: The should really be asserted as object -created_by-> CreationEvent -part-> SubEvent # however, right now that assertion would get lost as it's data that belongs to the object, # and we're on the author's chain in the bonobo graph; object serialization has already happened. # we need to serialize the object's relationship to the creation event, and let it get merged # with the rest of the object's data. event.part = subevent role = a.get('creation_role') if role is not None: subevent._label = f'Creation sub-event for {role} by “{person_name}”' subevent.carried_out_by = person yield data
def static_db_instance(self, *keys, **kwargs): uri = self.helper.make_shared_uri('DB', *keys) label = ' '.join(keys) name = kwargs.get('name', f'STAR {label} Database') db = vocab.Database(ident=uri, label=name) db.identified_by = vocab.PrimaryName(ident='', content=name) creator = kwargs.get('creator') if creator: creation = model.Creation(ident='') creation.carried_out_by = creator db.created_by = creation return db
def __call__(self, data: dict): '''Add modeling for the entry describing a person/group in the PSCP PEOPLE dataset.''' recno = data['star_record_no'] auth_name = data.get('auth_name') record_uri = self.helper.make_proj_uri('ENTRY', 'PEOPLE', recno) content = data['star_csv_data'] record = vocab.EntryTextForm( ident=record_uri, label=f'Entry recorded in PSCP PEOPLE dataset for {auth_name}', content=content) creation = model.Creation(ident='') creation.carried_out_by = self.helper.static_instances.get_instance( 'Group', 'gpi') record.created_by = creation record.identified_by = self.helper.gpi_number_id( recno, vocab.StarNumber) record.identified_by = vocab.PrimaryName( ident='', content=f'STAR Person Authority Entry {recno}') record.part_of = self.helper.static_instances.get_instance( 'LinguisticObject', 'db-people') data['_entry_record'] = add_crom_data({'uri': record_uri}, record) yield data