def populate_destruction_events(self, data: dict, note, *, type_map, location=None): destruction_types_map = type_map hmo = get_crom_object(data) title = data.get('title') short_title = truncate_with_ellipsis(title, 100) or title r = re.compile( r'[Dd]estroyed(?: (?:by|during) (\w+))?(?: in (\d{4})[.]?)?') m = r.search(note) if m: method = m.group(1) year = m.group(2) # The destruction URI is just the object URI with a suffix. When URIs are # reconciled during prev/post sale rewriting, this will allow us to also reconcile # the URIs for the destructions (of which there should only be one per object) dest_uri = hmo.id + '-Destruction' d = model.Destruction(ident=dest_uri, label=f'Destruction of “{short_title}”') d.referred_to_by = vocab.Note(ident='', content=note) if year is not None: begin, end = date_cleaner(year) ts = timespan_from_outer_bounds(begin, end) ts.identified_by = model.Name(ident='', content=year) d.timespan = ts if method: with suppress(KeyError, AttributeError): type_name = destruction_types_map[method.lower()] otype = vocab.instances[type_name] event = model.Event( label= f'{method.capitalize()} event causing the destruction of “{short_title}”' ) event.classified_as = otype d.caused_by = event data['_events'].append(add_crom_data(data={}, what=event)) if location: current = parse_location_name( location, uri_base=self.helper.uid_tag_prefix) # The place URI used for destruction events is based on the object URI with # a suffix. When URIs are reconciled during prev/post sale rewriting, this # will allow us to also reconcile the URIs for the places of destruction # (of which there should only be one hierarchy per object) base_uri = hmo.id + '-Destruction-Place,' place_data = self.helper.make_place(current, base_uri=base_uri) place = get_crom_object(place_data) if place: data['_locations'].append(place_data) d.took_place_at = place hmo.destroyed_by = d
def populate_destruction_events(self, data: dict, note, *, type_map, location=None): destruction_types_map = type_map hmo = get_crom_object(data) title = data.get('title') short_title = truncate_with_ellipsis(title, 100) or title r = re.compile( r'[Dd]estroyed(?: (?:by|during) (\w+))?(?: in (\d{4})[.]?)?') m = r.search(note) if m: method = m.group(1) year = m.group(2) dest_id = hmo.id + '-Destr' d = model.Destruction(ident=dest_id, label=f'Destruction of “{short_title}”') d.referred_to_by = vocab.Note(ident='', content=note) if year is not None: begin, end = date_cleaner(year) ts = timespan_from_outer_bounds(begin, end) ts.identified_by = model.Name(ident='', content=year) d.timespan = ts if method: with suppress(KeyError, AttributeError): type_name = destruction_types_map[method.lower()] otype = vocab.instances[type_name] event = model.Event( label= f'{method.capitalize()} event causing the destruction of “{short_title}”' ) event.classified_as = otype d.caused_by = event data['_events'].append(add_crom_data(data={}, what=event)) if location: current = parse_location_name( location, uri_base=self.helper.uid_tag_prefix) base_uri = hmo.id + '-Place,' place_data = self.helper.make_place(current, base_uri=base_uri) place = get_crom_object(place_data) if place: data['_locations'].append(place_data) d.took_place_at = place hmo.destroyed_by = d
def active_timespan(self, century=None, date_range=None, **kwargs): ''' Return a TimeSpan object representing the period during which a person was active in their professional activities. If no such information is supplied, return None. ''' if century: ts = timespan_for_century(century, **kwargs) return ts elif date_range: b, e = date_range ts = timespan_from_outer_bounds(begin=b, end=e, inclusive=True) return ts return None
def model_sojourn(self, data, loc): base_uri = self.helper.make_proj_uri('PLACE', '') cb = data.get('corporate_body', False) sojourn_type = vocab.Establishment if cb else vocab.Residing sdata = { 'type': sojourn_type, 'referred_to_by': [], } verbatim_date = loc.get('address_date') if verbatim_date: date_range = date_cleaner(verbatim_date) if date_range: begin, end = date_range ts = timespan_from_outer_bounds(*date_range) ts.identified_by = model.Name(ident='', content=verbatim_date) sdata['timespan'] = add_crom_data( { 'address_date': verbatim_date, 'begin': begin, 'end': end }, ts) current = None l = loc.get('location') if l: current = parse_location_name(l, uri_base=self.helper.proj_prefix) address = loc.get('address') if address: current = { 'name': address, 'part_of': current, 'type': 'address', } for k in ('address_note', 'location_note'): note = loc.get(k) if note: sdata['referred_to_by'].append( vocab.Note(ident='', content=note)) if current: place_data = self.helper.make_place(current, base_uri=base_uri) data['_places'].append(place_data) sdata['place'] = place_data return sdata
def set_lot_date(lot, auction_data, event_dates): '''Associate a timespan with the auction lot.''' date = implode_date(auction_data, 'lot_sale_') if date: begin = implode_date(auction_data, 'lot_sale_', clamp='begin') end = implode_date(auction_data, 'lot_sale_', clamp='eoe') bounds = [begin, end] else: bounds = [] if bounds: if auction_data.get('lot_sale_mod'): # if the lot sale date is marked as uncertain: # - use the event end date as the lot sale's end_of_the_end # - if the event doesn't have a known end date, assert no end_of_the_end for the lot sale if event_dates and event_dates[1]: bounds[1] = event_dates[1] else: bounds[1] = None ts = timespan_from_outer_bounds(*bounds) ts.identified_by = model.Name(ident='', content=date) lot.timespan = ts
def __call__(self, data: dict, event_properties): '''Add modeling data for an auction event''' cno = data['catalog_number'] auction_locations = event_properties['auction_locations'] event_experts = event_properties['experts'] event_commissaires = event_properties['commissaire'] auction = get_crom_object(data) catalog = data['_catalog']['_LOD_OBJECT'] location_data = data['location'] current = self.auction_event_location(location_data) # helper.make_place is called here instead of using make_la_place as a separate graph node because the Place object # gets stored in the `auction_locations` object to be used in the second graph component # which uses the data to associate the place with auction lots. base_uri = self.helper.make_proj_uri('AUCTION-EVENT', cno, 'PLACE', '') place_data = self.helper.make_place(current, base_uri=base_uri) place = get_crom_object(place_data) if place: data['_locations'] = [place_data] auction.took_place_at = place auction_locations[cno] = place.clone(minimal=True) begin = implode_date(data, 'sale_begin_', clamp='begin') end = implode_date(data, 'sale_end_', clamp='eoe') ts = timespan_from_outer_bounds(begin=begin, end=end, inclusive=True) event_properties['auction_dates'][cno] = (begin, end) event_record = get_crom_object(data['_record']) for seq_no, expert in enumerate(data.get('expert', [])): self.helper.copy_source_information(expert, data), person = self.helper.add_person(expert, record=event_record, relative_id=f'expert-{seq_no+1}', role='expert') event_experts[cno].append(person.clone(minimal=True)) data['_organizers'].append(add_crom_data(data={}, what=person)) role_id = '' # self.helper.make_proj_uri('AUCTION-EVENT', cno, 'Expert', seq_no) role = vocab.Expert(ident=role_id, label=f'Role of Expert in the event {cno}') role.carried_out_by = person auction.part = role for seq_no, commissaire in enumerate(data.get('commissaire', [])): self.helper.copy_source_information(commissaire, data), person = self.helper.add_person( commissaire, record=event_record, relative_id=f'commissaire-{seq_no+1}', role='commissaire') event_commissaires[cno].append(person.clone(minimal=True)) data['_organizers'].append(add_crom_data(data={}, what=person)) role_id = '' # self.helper.make_proj_uri('AUCTION-EVENT', cno, 'Commissaire', seq_no) role = vocab.CommissairePriseur( ident=role_id, label=f'Role of Commissaire-priseur in the event {cno}') role.carried_out_by = person auction.part = role notes = data.get('notes') if notes: auction.referred_to_by = vocab.Note(ident='', content=notes) if begin and end: ts.identified_by = model.Name(ident='', content=f'{begin} to {end}') elif begin: ts.identified_by = model.Name(ident='', content=f'{begin} onwards') elif end: ts.identified_by = model.Name(ident='', content=f'up to {end}') for p in data.get('portal', []): url = p['portal_url'] if url.startswith('http'): auction.referred_to_by = vocab.WebPage(ident=url, label=url) else: warnings.warn( f'*** Portal URL value does not appear to be a valid URL: {url}' ) if ts: auction.timespan = ts auction.referred_to_by = catalog return data