def compare_event_and_place_data(event_links1, event_links2): global points events1 = [] places1 = [] for link in event_links1: event = Event() event.uniq_id = link event.get_event_data_by_id() events1.append(event) pname1 = '' if event.place_hlink != '': place = Place() place.uniq_id = event.place_hlink place.get_place_data_by_id() pname1 = place.pname places1.append(pname1) events2 = [] places2 = [] for link in event_links2: event = Event() event.uniq_id = link event.get_event_data_by_id() events2.append(event) pname2 = '' if event.place_hlink != '': place = Place() place.uniq_id = event.place_hlink place.get_place_data_by_id() pname2 = place.pname places2.append(pname2) for i in range(len(events1)): for j in range(len(events2)): if events1[i].type == events2[j].type: local_points = events1[i].get_points_for_compared_data( events2[j], places1[i], places2[j]) print("--- --- Local points: " + str(local_points) + " --- ---") points += local_points
def compare_event_and_place_data(event_links1, event_links2): events1 = [] places1 = [] for link in event_links1: event = Event() event.handle = link event.get_event_data() events1.append(event) pname1 = '' if event.place_hlink != '': place = Place() place.handle = event.place_hlink place.get_place_data() pname1 = place.pname places1.append(pname1) events2 = [] places2 = [] for link in event_links2: event = Event() event.handle = link event.get_event_data() events2.append(event) pname2 = '' if event.place_hlink != '': place = Place() place.handle = event.place_hlink place.get_place_data() pname2 = place.pname places2.append(pname2) for i in range(len(events1)): for j in range(len(events2)): if events1[i].type == events2[j].type: events1[i].print_compared_data(events2[j], places1[i], places2[j])
def get_event_and_place_data(event_link): event = Event() event.handle = event_link event.get_event_data() event.print_data() if event.place_hlink != '': place = Place() place.handle = event.place_hlink place.get_place_data() place.print_data()
def handle_events(collection, userid): # Get all the events in the collection events = collection.getElementsByTagName("event") print("*****Events*****") counter = 0 # Print detail of each event for event in events: e = Event() if event.hasAttribute("handle"): e.handle = event.getAttribute("handle") if event.hasAttribute("change"): e.change = event.getAttribute("change") if event.hasAttribute("id"): e.id = event.getAttribute("id") if len(event.getElementsByTagName('type')) == 1: event_type = event.getElementsByTagName('type')[0] # If there are type tags, but no type data if (len(event_type.childNodes) > 0): e.type = event_type.childNodes[0].data else: e.type = '' elif len(event.getElementsByTagName('type')) > 1: print("Error: More than one type tag in an event") if len(event.getElementsByTagName('description')) == 1: event_description = event.getElementsByTagName('description')[0] # If there are description tags, but no description data if (len(event_description.childNodes) > 0): e.description = event_description.childNodes[0].data else: e.description = '' elif len(event.getElementsByTagName('description')) > 1: print("Error: More than one description tag in an event") if len(event.getElementsByTagName('dateval')) == 1: event_dateval = event.getElementsByTagName('dateval')[0] if event_dateval.hasAttribute("val"): e.date = event_dateval.getAttribute("val") elif len(event.getElementsByTagName('dateval')) > 1: print("Error: More than one dateval tag in an event") if len(event.getElementsByTagName('place')) == 1: event_place = event.getElementsByTagName('place')[0] if event_place.hasAttribute("hlink"): e.place_hlink = event_place.getAttribute("hlink") elif len(event.getElementsByTagName('place')) > 1: print("Error: More than one place tag in an event") if len(event.getElementsByTagName('attribute')) == 1: event_attr = event.getElementsByTagName('attribute')[0] if event_attr.hasAttribute("type"): e.attr_type = event_attr.getAttribute("type") if event_attr.hasAttribute("value"): e.attr_value = event_attr.getAttribute("value") elif len(event.getElementsByTagName('attribute')) > 1: print("Error: More than one attribute tag in an event") if len(event.getElementsByTagName('citationref')) == 1: event_citationref = event.getElementsByTagName('citationref')[0] if event_citationref.hasAttribute("hlink"): e.citationref_hlink = event_citationref.getAttribute("hlink") elif len(event.getElementsByTagName('citationref')) > 1: print("Error: More than one citationref tag in an event") e.save(userid) # There can be so many individs to store that Cypher needs a pause time.sleep(0.1) counter += 1 print("Number of events stored: " + str(counter))
def number_of_events(): print("Number of events in db: " + Event.get_total())