def __insert_di_act( self, event: Event, row: Series = pandas.Series(), authors: str = "", source_label: str = "", source_location_label: str = "", interpretation_date_text: Optional[str] = None, ): author_label = authors source_label = source_label source_location_label = source_location_label author = authors # Author(self._graph, author_label) if not author: return None source_location = self.__get_source_location(source_label, source_location_label) interpretation_date = interpretation_date_text comment = None if comment: event.add_comment(comment) Di_act( self._graph, event, author, source_location, interpretation_date, )
def __insert_di_act( self, event: Event, row: Series = pandas.Series(), author_label: str = "", source_label: str = "", source_location_label: str = "", interpretation_date_text: Optional[str] = None, ): source_label = row[ Column.source] if Column.source in row else source_label source_location_label = (row[Column.source_location] if Column.source_location in row else source_location_label) source_location = self.__get_source_location(source_label, source_location_label) interpretation_date = (row[Column.interpretation_date] if Column.interpretation_date in row else interpretation_date_text) comment = row[Column.comment] if Column.comment in row else None if comment: event.add_comment(comment) Di_act( self._graph, event, ["Patrick Fiska", "Irene Rabl"], source_location, interpretation_date, )
def F(): # FT FROM PROXEL EXAMPLE rel_exp_dist = ['EXP', 1 / 3] main_exp_dist = ['EXP', 1 / 2] lognorm_dist = ['LOGNORM', 2, 1] norm_dist = ['NORMAL', 4, 1] weibull = ['WEIBULL', 5, 2] top_event = Event("Top Event") and1 = Gate("AND", parent=top_event) intermediate_event_1 = Event("Intermediate Event 1", parent=and1) intermediate_event_2 = Event("Intermediate Event 2", parent=and1) voting2 = Gate("VOTING", parent=intermediate_event_1, k=2) basic_event_3 = Event("Basic Event 3", norm_dist, ['LOGNORM', 4, 1], parent=voting2) basic_event_4 = Event("Basic Event 4", rel_exp_dist, weibull, parent=voting2) basic_event_5 = Event("Basic Event 5", lognorm_dist, main_exp_dist, parent=voting2) or3 = Gate("OR", parent=intermediate_event_2) basic_event_1 = Event("Basic Event 1", norm_dist, main_exp_dist, parent=or3) basic_event_2 = Event("Basic Event 2", ['EXP', 1 / 3], norm_dist, parent=or3) FT = FaultTree(top_event) return FT
def B(): topEvent = Event('Top Event') and1 = Gate('AND', parent=topEvent) basicEvent1 = Event('Basic Event 1', rel_exp_dist, main_exp_dist, parent=and1) basicEvent2 = Event('Basic Event 2', ['EXP', 1 / 6], main_exp_dist, parent=and1) fault_tree = FaultTree(topEvent) return fault_tree
def H(): # SECOND PROXEL EXAMPLE rel_exp_dist = ['EXP', 1 / 3] main_exp_dist = ['EXP', 1 / 2] lognorm_dist = ['LOGNORM', 4, 1] norm_dist = ['NORMAL', 4, 1] weibull = ['WEIBULL', 5, 2] top_event = Event("Top Event") and1 = Gate("AND", parent=top_event) intermediate_event_1 = Event("Intermediate Event 1", parent=and1) intermediate_event_2 = Event("Intermediate Event 2", parent=and1) and2 = Gate("AND", parent=intermediate_event_1, k=2) basic_event_1 = Event("Basic Event 1", norm_dist, main_exp_dist, parent=and2) basic_event_2 = Event("Basic Event 2", ['EXP', 1 / 10], norm_dist, parent=and2) or3 = Gate("OR", parent=intermediate_event_2) basic_event_3 = Event("Basic Event 3", norm_dist, main_exp_dist, parent=or3) basic_event_4 = Event("Basic Event 4", lognorm_dist, weibull, parent=or3) fault_tree = FaultTree(top_event) return fault_tree
def add_event(): event_name = request.form["name"] event_date = request.form["date"] guest_num = request.form["guests"] event_room = request.form["room"] event_description = request.form["description"] new_event = Event(event_name, event_date, guest_num, event_room, event_description, False, False) add_new_event(new_event) return render_template("index.html", title = "Home", events = events)
def scheduleEvent(self, event: Event) -> None: """Programa o próximo evento Args: event (Event): Próximo evento """ evtAux = self.first_event evtAnt = None while(evtAux != None): if(event.getTime() < evtAux.getTime()): break else: evtAnt = evtAux evtAux = evtAux.getNextEvent() event.setNextEvent(evtAux) if(evtAnt == None): self.first_event = event else: evtAnt.setNextEvent(event)
def __add_independent_titles(self): title_query = """ PREFIX core: <http://purl.org/nampi/owl/core#> PREFIX mona: <http://purl.org/nampi/owl/monastic-life#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?text WHERE {{ ?event a core:event ; core:assigns_title/core:has_xsd_string ?text ; core:assigns_title_to/rdfs:label "{}" . }} """ for _, row in self.__sheet.get_table(Table.PERSONS).iterrows(): religious_title = safe_str(row, Column.religious_title) person_label = safe_str(row, Column.name) if religious_title: has_existing_title = bool( self._graph.graph.query(title_query.format(person_label))) if not has_existing_title: person = self.__get_person(person_label) if person: assert person_label event = Event( self._graph, person, label="Assign religious title " + religious_title, main_person_relationship=Nampi_type.Core. has_main_participant, ) title = Title( self._graph, religious_title, Nampi_type.Mona.religious_title, ) event.add_relationship(Nampi_type.Core.adds_aspect, title) self.__insert_di_act(event, row) logging.debug("Assigns title '{}' to '{}'".format( religious_title, person_label)) logging.info("Finish adding independent titles")
def createEvent(self, titulo, start="", end="", emails=[], description="", location=None): ''' Método responsável por criar um evento. TODO: Implementar a passagem de parâmetros para poder criar os eventos reais. ''' attendees = list(map(lambda x: {'email': x}, emails)) # Emails a serem convidados event = Event(titulo, location, description, start, end, attendees) event = self.service.events().insert(calendarId='primary', body=event.body).execute() print( 'Evento criado com sucesso! Segue o link para vê-lo no seu Google Agenda: %s' % (event.get('htmlLink')))
def upload_event(): try: data = { 'author': request.args.get('app'), 'level': request.args.get('level').upper(), 'text': request.args.get('text').replace('_', ' ') } except AttributeError: return failure_response( 'Usage: /upload_event?app=<app>&level=<level>&text=<your_text>') event = Event.from_json(data, host=request.remote_addr) return event.to_db()
def add_event(): print(request.form) date = request.form["name-of-event"] name = request.form["date"] number_of_guests = request.form["number-of-guests"] room_location = request.form["room-location"] description = request.form["description"] is_recurring = request.form.get("recurring") if is_recurring == None: is_recurring = False else: is_recurring = True new_event = Event(date, name, number_of_guests, room_location, description, is_recurring) add_event_to_events(new_event) return render_template("index.html", title="title", events=events)
def merge_event(): nonlocal event, main_person, definition if event: return event place = self.__get_place(safe_str(row, Column.event_place)) assert main_person is not None event = Event( self._graph, main_person, place=place, earliest_date=safe_str(row, Column.earliest_date), exact_date=safe_str(row, Column.exact_date), latest_date=safe_str(row, Column.latest_date), label=str(definition), other_participants=other_participants, ) return event
def A(): top_event = Event("Top Event") and1 = Gate("AND", parent=top_event) intermediate_event_1 = Event("Intermediate Event 1", parent=and1) intermediate_event_2 = Event("Intermediate Event 2", parent=and1) voting2 = Gate("VOTING", parent=intermediate_event_1, k=3) basic_event_4 = Event("Basic Event 4", rel_exp_dist, lognorm_dist, parent=voting2) basic_event_5 = Event("Basic Event 5", norm_dist, main_exp_dist, parent=voting2) basic_event_6 = Event("Basic Event 6", lognorm_dist, main_exp_dist, parent=voting2) voting3 = Gate("VOTING", parent=intermediate_event_2, k=1) basic_event_1 = Event("Basic Event 1", weibull_dist, main_exp_dist, parent=voting3) basic_event_2 = Event("Basic Event 2", rel_exp_dist, lognorm_dist, parent=voting3) basic_event_3 = Event("Basic Event 3", weibull_dist, main_exp_dist, parent=voting3) fault_tree = FaultTree(top_event) return fault_tree
def E(): topEvent = Event('Top Event') and1 = Gate('AND', parent=topEvent) intermediateEvent1 = Event('Intermediate Event 1', parent=and1) intermediateEvent2 = Event('Intermediate Event 2', parent=and1) and2 = Gate('AND', parent=intermediateEvent1) basicEvent1 = Event('Basic Event 1', ['EXP', 1 / 15], ['EXP', 1 / 5], parent=and2) basicEvent2 = Event('Basic Event 2', ['NORMAL', 12, 2], ['NORMAL', 5, 1], parent=and2) or3 = Gate('OR', parent=intermediateEvent2) basicEvent3 = Event('Basic Event 3', ['LOGNORM', 3, 1], ['LOGNORM', 2, 1], parent=or3) basicEvent4 = Event('Basic Event 4', ['WEIBULL', 10, 8], ['WEIBULL', 5, 2], parent=or3) fault_tree = FaultTree(topEvent) return fault_tree
def D(): topEvent = Event('Top Event') or1 = Gate('OR', parent=topEvent) intermediateEvent1 = Event('Intermediate Event 1', parent=or1) intermediateEvent2 = Event('Intermediate Event 2', parent=or1) vote2 = Gate('VOTING', parent=intermediateEvent1, k=2) basicEvent1 = Event('Basic Event 1', lognorm_dist, norm_dist, parent=vote2) basicEvent2 = Event('Basic Event 2', ['EXP', 1 / 10], weibull_dist, parent=vote2) basicEvent3 = Event('Basic Event 3', rel_exp_dist, main_exp_dist, parent=vote2) and2 = Gate('AND', parent=intermediateEvent2) basicEvent4 = Event('Basic Event 4', norm_dist, main_exp_dist, parent=and2) basicEvent5 = Event('Basic Event 5', ['EXP', 1 / 10], lognorm_dist, parent=and2) fault_tree = FaultTree(topEvent) return fault_tree
def G(): topEvent = Event('Top Event') or1 = Gate('OR', parent=topEvent) intermediateEvent1 = Event('Intermediate Event 1', parent=or1) intermediateEvent2 = Event('Intermediate Event 2', parent=or1) or2 = Gate('OR', parent=intermediateEvent1) basicEvent1 = Event('Basic Event 1', lognorm_dist, norm_dist, parent=or2) basicEvent2 = Event('Basic Event 2', rel_exp_dist, weibull_dist, parent=or2) or3 = Gate('OR', parent=intermediateEvent2) basicEvent3 = Event('Basic Event 3', rel_exp_dist, main_exp_dist, parent=or3) basicEvent4 = Event('Basic Event 4', norm_dist, main_exp_dist, parent=or3) fault_tree = FaultTree(topEvent) return fault_tree
from modules.event import Event event_1 = Event("Danny's Birthday", "14-04-2021", 50, "Grand Ballroom", "An elegant birthday bash!", True, True) event_2 = Event("Buff Bash", '15-09-2021', 35, 'Snug Bar', 'Nudist Party', False, False) event_3 = Event("Summer Party", '20-07-2021', 60, 'Secret Garden', 'Celebration of Summer', False, False) events = [event_1, event_2, event_3] def add_new_event(event): events.append(event)
from modules.gate import Gate from modules.event import Event from modules.faulttree import FaultTree rel_exp_dist = ['EXP', 1 / 3] main_exp_dist = ['EXP', 1 / 2] lognorm_dist = ['LOGNORM', 2, 1] norm_dist = ['NORMAL', 4, 1] weibull = ['WEIBULL', 5, 2] top_event = Event("Top Event") and1 = Gate("AND", parent=top_event) intermediate_event_1 = Event("Intermediate Event 1", parent=and1) intermediate_event_2 = Event("Intermediate Event 2", parent=and1) voting2 = Gate("VOTING", parent=intermediate_event_1, k=2) basic_event_3 = Event("Basic Event 3", norm_dist, main_exp_dist, parent=voting2) basic_event_4 = Event("Basic Event 4", rel_exp_dist, weibull, parent=voting2) basic_event_5 = Event("Basic Event 5", lognorm_dist, main_exp_dist, parent=voting2) or3 = Gate("OR", parent=intermediate_event_2) basic_event_1 = Event("Basic Event 1", norm_dist, main_exp_dist, parent=or3) basic_event_2 = Event("Basic Event 2", rel_exp_dist, norm_dist, parent=or3) FT = FaultTree(top_event) FT.generate_basic_event_time_series(4)
main_exp_dist = ['EXP', 1 / 2] ''' topEvent = Event('Top Event') and1 = Gate('AND', parent=topEvent) basicEvent1 = Event('Basic Event 1', rel_exp_dist, main_exp_dist, parent=and1) basicEvent2 = Event('Basic Event 2', ['EXP', 1 / 100], main_exp_dist, parent=and1) ''' ''' intermed = Event('Inter event ', parent=or1) and1 = Gate('AND', parent=intermed) basicEvent3 = Event('Basic Event 3', lognorm_dist, norm_dist, parent=and1) basicEvent4 = Event('Basic Event 4', rel_exp_dist, main_exp_dist, parent=and1) ''' topEvent = Event('Top Event') and1 = Gate('AND', parent=topEvent) intermediateEvent1 = Event('Intermediate Event 1', parent=and1) intermediateEvent2 = Event('Intermediate Event 2', parent=and1) vote2 = Gate('VOTING', parent=intermediateEvent1, k=2) basicEvent1 = Event('Basic Event 1', rel_exp_dist, main_exp_dist, parent=vote2) basicEvent2 = Event('Basic Event 2', rel_exp_dist, main_exp_dist, parent=vote2) intermediateEvent3 = Event('Intermediate Event 3', parent=vote2) and2 = Gate('AND', parent=intermediateEvent3) basicEvent3 = Event('Basic Event 3', rel_exp_dist, main_exp_dist, parent=and2) basicEvent4 = Event('Basic Event 4', rel_exp_dist, main_exp_dist, parent=and2) or1 = Gate('OR', parent=intermediateEvent2) basicEvent5 = Event('Basic Event 5', rel_exp_dist, main_exp_dist, parent=or1) intermediateEvent4 = Event('Intermediate Event 4', parent=or1) and3 = Gate('AND', parent=intermediateEvent4) basicEvent6 = Event('Basic Event 6', rel_exp_dist, main_exp_dist, parent=and3)
def __add_investiture_events_for_professions(self): """ Add investiture events for persons that have specific profession events """ professions_query = """ PREFIX core: <http://purl.org/nampi/owl/core#> PREFIX mona: <http://purl.org/nampi/owl/monastic-life#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?author ?authoring_date ?source ?source_location ?group ?person_node ?person ?place ?exact_date ?earliest_date ?latest_date WHERE { ?event_node a core:event ; rdfs:label ?event_label . ?dia_node core:has_interpretation ?event_node ; core:is_authored_by/rdfs:label ?author ; core:is_authored_on/core:has_date_time ?authoring_date ; core:has_source_location ?source_node . ?source_node (core:has_source|core:has_online_source|mona:has_paged_source)/rdfs:label ?source ; (core:has_value|core:has_text|core:has_url|mona:has_page_number) ?source_location . ?event_node core:changes_aspect_related_to/rdfs:label ?group ; core:has_main_participant ?person_node . ?person_node rdfs:label ?person . OPTIONAL { ?event_node core:takes_place_at/rdfs:label ?place } OPTIONAL { ?event_node core:takes_place_on/core:has_date_time ?exact_date } OPTIONAL { ?event_node core:takes_place_not_later_than/core:has_date_time ?latest_date } OPTIONAL { ?event_node core:takes_place_not_earlier_than/core:has_date_time ?earliest_date } VALUES ?event_label { "Profession as choir monk in Astheim" "Profession as choir monk in Bistra" "Profession as choir monk in Gaming" "Profession as choir monk in Žiče" "Profession as choir nun in Imbach" "Profession as choir nun in St. Jakob" "Profession as converse in Gaming" "Profession as lay sister in Imbach" "Profession as priest monk in Gaming" "Profession as choir nun in St. Laurenz" "Profession as choir monk in Brno" "Second profession as choir nun in Imbach" "Secret profession as choir nun in Imbach" } } """ has_investiture_event_query = """ PREFIX core: <http://purl.org/nampi/owl/core#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ASK WHERE {{ ?event core:has_main_participant <{}> ; rdfs:label ?label . FILTER ( CONTAINS(LCASE(?label), "investiture") ) }} """ for row in self._graph.graph.query(professions_query): has_investiture_event = bool( self._graph.graph.query( has_investiture_event_query.format(row["person_node"]))) if not has_investiture_event: person = self.__get_person(str(row["person"])) if not person: continue status_type = self.__get_status_type(added_investiture_label) aspect = Aspect(self._graph, added_investiture_label, status_type) author_label = str(row["author"]) interpretation_date_text = str( row["authoring_date"]).partition("T")[0] source_label = str(row["source"]) source_location_label = str(row["source_location"]) group = self.__get_group(str(row["group"])) assert group is not None place = self.__get_place(str(row["place"])) exact_date = (str(row["exact_date"]).partition("T")[0] if row["exact_date"] else None) earliest_date = (str(row["earliest_date"]).partition("T")[0] if row["earliest_date"] else None) latest_date = (str(row["latest_date"]).partition("T")[0] if row["latest_date"] else None) dates_sorted_by_specificity = [ exact_date, latest_date, earliest_date ] most_specific_date = next( (s for s in dates_sorted_by_specificity if s), None) event = Event( self._graph, person, main_person_relationship=Nampi_type.Core. has_main_participant, place=place, latest_date=most_specific_date, label="Investiture in " + str(group.label), ) event.add_relationship( obj=group, pred=Nampi_type.Core.changes_aspect_related_to) event.add_relationship(obj=aspect, pred=Nampi_type.Core.adds_aspect) self.__insert_di_act( event, author_label=author_label, source_label=source_label, source_location_label=source_location_label, interpretation_date_text=interpretation_date_text, ) logging.debug( "Added investiture event and interpretation for '{}'". format(person.label)) logging.info("Finished adding investiture events")
def test_trigger_units_of_example_1(self): polymer = 'dabAcCaCBAcCcaDA' result = Event().trigger_units_of(polymer) self.assertEqual(result, 'dabCBAcaDA')
def __add_persons(self): """ Add all persons from the persons table not being added in birth events. """ for _, row in self.__sheet.get_table(Table.PERSONS).iterrows(): if not row[Column.source]: # Only use entries with source logging.warning( "No source entry for 'person' table row '{}'".format( row[Column.name])) continue person_label = safe_str(row, Column.name) has_birth_event = self.__sheet.table_has_value( Table.BIRTHS, Column.person, person_label, ) person = self.__get_person(safe_str(row, Column.name)) if not person: continue if not has_birth_event: # Get all family name variants from the person table family_names = [ safe_str(row, Column.family_name_with_group), safe_str(row, Column.family_name_gender_neutral), safe_str(row, Column.family_name), ] # Get the official family name by looking through the ordered family_names list and picking the first match family_group_name = next((s for s in family_names if s), None) # Add family name group membership if family_group_name: family = Family(self._graph, family_group_name) aspect = Aspect(self._graph, family_member_label) become_member_event = Event( self._graph, person, Nampi_type.Core.has_main_participant, label="Become family member", ) become_member_event.add_relationship( Nampi_type.Core.adds_aspect, aspect) become_member_event.add_relationship( Nampi_type.Core.changes_aspect_related_to, family) self.__insert_di_act(become_member_event, row=row) logging.debug( "Added 'membership' in family '{}' for birthless person '{}'" .format(family.label, row[Column.name])) # Add names for persons that don't have birth events if family_names[2]: # Add personal family name fn_assignment = Appellation_assignment( self._graph, person, family_names[2], Appellation_type.FAMILY_NAME, ) self.__insert_di_act(fn_assignment, row=row) if row[Column.given_name]: # Add given name gn_assignment = Appellation_assignment( self._graph, person, str(safe_str(row, Column.given_name))) self.__insert_di_act(gn_assignment, row=row) logging.debug("Added 'names' for birthless person '{}'".format( row[Column.name])) logging.info("Parsed the persons")
from string import ascii_lowercase from modules.event import Event filename = 'input' in_filepath = f'data/{filename}.plain' polymer = open(in_filepath).read().split('\n')[0] result = Event().trigger_units_of(polymer) # print(f'result: {result}') print('Part 1') print(f'result: {len(result)}') print('= = = = =') print('Part 2') min_len = len(polymer) for c in ascii_lowercase: opposite_uniy_type = c.swapcase() processed_polymer = polymer.replace(c, '').replace(opposite_uniy_type, '') result = Event().trigger_units_of(processed_polymer) result_len = len(result) min_len = min(min_len, result_len) print(f'min len: {min_len}')
def add_persons(self, persondata, birthdate="", birthplace="", ids=""): """ Add all persons from the persons table not being added in birth events. """ if not persondata: # Only use entries with source logging.warning("No source entry for 'person' ") return person_label = persondata.Name # persondata.Forename + " " + persondata.Surname person = self.__get_person(persondata.Name) print("Person in Progress...{}") if person: # if not has_birth_event: # # Get all family name variants from the person table family_names = persondata.Surname # safe_str(row, Column.family_name_gender_neutral), safe_str(row, Column.family_name)] # # Get the official family name by looking through the ordered family_names list and picking the first match family_group_name = next((s for s in family_names if s), None) # Add family name group membership family = Family(self._graph, persondata.Surname) aspect = Aspect(self._graph, family_member_label) if len(family_names) != 0: become_member_event = Event( self._graph, person, Nampi_type.Core.has_main_participant, label="Become family member", ) become_member_event.add_relationship( Nampi_type.Core.adds_aspect, aspect) become_member_event.add_relationship( Nampi_type.Core.changes_aspect_related_to, family) logging.debug("Added 'membership' in family ") self.__insert_di_act( become_member_event, (), authors, "ProDomo", "https://prodomo.icar-us.eu/person/" + persondata.Id, self._d1, ) if len(persondata.Mother) != 0: mother = self.__get_person(persondata.Mother) become_member_event_mother = Event( self._graph, mother, Nampi_type.Core.has_main_participant, label="Become family member", ) become_member_event_mother.add_relationship( Nampi_type.Core.adds_aspect, aspect) become_member_event_mother.add_relationship( Nampi_type.Core.changes_aspect_related_to, family) self.__insert_di_act( become_member_event_mother, (), authors, "ProDomo", "https://prodomo.icar-us.eu/aspekt/" + ids["Mutter"], self._d1, ) if len(persondata.Father) != 0: father = self.__get_person(persondata.Father) become_member_event_father = Event( self._graph, father, Nampi_type.Core.has_main_participant, label="Become family member", ) become_member_event_father.add_relationship( Nampi_type.Core.adds_aspect, aspect) become_member_event_father.add_relationship( Nampi_type.Core.changes_aspect_related_to, family) self.__insert_di_act( become_member_event_father, (), authors, "ProDomo", "https://prodomo.icar-us.eu/aspekt/" + ids["Vater"], self._d1, ) # Add names for persons that don't have birth events # if family_names: # Add personal family name fn_assignment = Appellation_assignment( self._graph, person, family_names, Appellation_type.FAMILY_NAME, ) self.__insert_di_act( fn_assignment, (), authors, "ProDomo", "https://prodomo.icar-us.eu/person/" + persondata.Id, self._d1, ) if birthdate: self.__add_births( birthdate, person_label, family_names, birthplace, ids["Geburt"], persondata.Mother, persondata.Father, ) logging.info("Parsed the persons")
def add_investiture_events(self, person, invest_dates): # get Event label from dict # print(invest_date.SemanticStm) # print(Entities_dict.keys()) if not isinstance(invest_dates, list): # If type is not list then make it list invest_dates = [invest_dates] for invest_date in invest_dates: if (invest_date.SemanticStm in Entities_dict and Entities_dict[invest_date.SemanticStm] is not None): Monastery = Entities_dict[invest_date.SemanticStm] elif (invest_date.Reference in Entities_dict and Entities_dict[invest_date.Reference] is not None): Monastery = Entities_dict[invest_date.Reference] else: Monastery = "" strPlace = "" if hasattr(Monastery, "Place_Label"): strPlace = Monastery.Place_Label Place = self.__get_place(strPlace, Monastery.GeoId) Person = self.__get_person(person.Name) Religious_Name = Appellation(self._graph, person.Forename, Appellation_type.RELIGIOUS_NAME) Novice = Aspect(self._graph, "Novice", Nampi_type.Mona.member_of_a_religious_community) investiture = Event( self._graph, Person, Nampi_type.Core.has_main_participant, "Investiture in " + Monastery.Event, Nampi_type.Core.event, Place, invest_date.When, ) if type(Monastery) is Entity_Importer: Kloster = self.__get_group(Monastery.Class, Monastery.Label, Monastery.Part_Of_Label) investiture.add_relationship( Nampi_type.Core.changes_aspect_related_to, Kloster) investiture.add_relationship(Nampi_type.Core.adds_aspect, Religious_Name.node) investiture.add_relationship(Nampi_type.Core.adds_aspect, Novice) # investiture.add_relationship(Nampi_type.Core.changes_aspect_related_to, Group) self.__insert_di_act( investiture, (), authors, "ProDomo", "https://prodomo.icar-us.eu/aspect/" + invest_date.Id, self._d1, )
def add_other_events( self, person: Person, label: str, date: str, semantics: Optional[str], reference: Optional[str], aspect: Optional[str], aspectkey: Optional[str], occupationkey: Optional[str], aspectlabel, name: Optional[str], participant: Optional[str], id: Optional[str], place: Optional[str], datefrom: Optional[str], dateto: Optional[str], ): # get Event label from dict Monastery = None Kloster = None if semantics in Entities_dict and Entities_dict[semantics] is not None: Monastery = Entities_dict[semantics] elif reference in Entities_dict and Entities_dict[ reference] is not None: Monastery = Entities_dict[reference] else: Monastery = "" if not person: # Only use entries with source logging.warning("No source entry for 'person' ") return Person = self.__get_person(person.Name) strPlace = "" Place = "" place = "" if hasattr(Monastery, "Place_Label"): strPlace = Monastery.Place_Label Place = self.__get_place(strPlace, Monastery.GeoId) elif place: Place = self.__get_place(place, "") # check date # if it contains 4 digits, make earliest and latest date dateearly = "" datelast = "" datetokens = "" if date: if len(date) == 4: dateearly = date + "-01-01" datelast = date + "-12-31" date = None elif len(date) == 7: datetokens = date.split("-") dateearly = date + "-01" datelast = (date + "-" + str( calendar.monthrange(int(datetokens[0]), int( datetokens[1]))[1])) date = None if datefrom: if (len(datefrom)) == 4: dateearly = datefrom + "-01-01" elif (len(datefrom)) == 7: dateearly = datefrom + "-01" else: dateearly = datefrom if dateto: if (len(dateto.strip())) == 4: datelast = dateto + "-12-31" elif (len(dateto.strip())) == 7: datetokens = dateto.split("-") datelast = (dateto + "-" + str( calendar.monthrange(int(datetokens[0]), int( datetokens[1]))[1])) else: datelast = dateto if dateearly == "0000-00-00": dateearly = "" if datelast == "0000-00-00": datelast = "" if dateearly.find("0000") > -1: dateearly = "" if datelast.find("0000") > -1: datelast = "" if len(dateearly) > 0: PlainEvent = Event( self._graph, Person, Nampi_type.Core.has_main_participant, label, Nampi_type.Core.event, Place, "", dateearly, datelast, ) elif date: PlainEvent = Event( self._graph, Person, Nampi_type.Core.has_main_participant, label, Nampi_type.Core.event, Place, date, ) else: PlainEvent = Event( self._graph, Person, Nampi_type.Core.has_main_participant, label, Nampi_type.Core.event, Place, ) if type(Monastery) is Entity_Importer: Kloster = self.__get_group(Monastery.Class, Monastery.Label, Monastery.Part_Of_Label) PlainEvent.add_relationship( Nampi_type.Core.changes_aspect_related_to, Kloster) # get various type by key from dict # leave if not present; core:aspect will be set automatically types = [] try: if len(str(aspectkey)) > 0: types.append(_status_types[aspectkey]) if len(occupationkey) > 0: types.append(_occupation_types[occupationkey]) if len(types) == 0: types.append(_status_types["Unspecified"]) except: logging.info("Key not in Dict") varAspect = "" alabel = "" if aspectlabel is not None: if aspectlabel.find("[Orden]") > -1 and hasattr( Monastery, "AspectPart"): alabel = aspectlabel.replace("[Orden]", Monastery.AspectPart) else: alabel = aspectlabel if alabel is not None and len(alabel.strip()) > 0: varAspect = Aspect(self._graph, alabel.capitalize(), types) PlainEvent.add_relationship(Nampi_type.Core.adds_aspect, varAspect) self.__insert_di_act( PlainEvent, (), authors, "ProDomo", "https://prodomo.icar-us.eu/aspect/" + id, self._d1, )
def C(): rel_exp = ['EXP', 1 / 9] topEvent = Event('Top Event') and1 = Gate('AND', parent=topEvent) intermediateEvent1 = Event('Intermediate Event 1', parent=and1) intermediateEvent2 = Event('Intermediate Event 2', parent=and1) vote2 = Gate('VOTING', parent=intermediateEvent1, k=2) basicEvent1 = Event('Basic Event 1', rel_exp, main_exp_dist, parent=vote2) basicEvent2 = Event('Basic Event 2', rel_exp, main_exp_dist, parent=vote2) intermediateEvent3 = Event('Intermediate Event 3', parent=vote2) and2 = Gate('AND', parent=intermediateEvent3) basicEvent3 = Event('Basic Event 3', rel_exp_dist, main_exp_dist, parent=and2) basicEvent4 = Event('Basic Event 4', rel_exp_dist, main_exp_dist, parent=and2) or1 = Gate('OR', parent=intermediateEvent2) basicEvent5 = Event('Basic Event 5', rel_exp, main_exp_dist, parent=or1) intermediateEvent4 = Event('Intermediate Event 4', parent=or1) and3 = Gate('AND', parent=intermediateEvent4) basicEvent6 = Event('Basic Event 6', rel_exp_dist, main_exp_dist, parent=and3) basicEvent7 = Event('Basic Event 7', rel_exp_dist, main_exp_dist, parent=and3) basicEvent8 = Event('Basic Event 8', rel_exp_dist, main_exp_dist, parent=and3) fault_tree = FaultTree(topEvent) return fault_tree