def test_date_check(self):
        '''
        Test of the function for date check
        '''
        event4end = event_profile("death")
        event4end.setDate(2014, accuracy="ABOUT")
        event2bend = event_profile("burial")
        event2bend.setDate(2014, month=2, day=1, accuracy="BEFORE")
        #Test bug of burial and death
        assert (checkDateConsistency([event4end, event2bend]))

        #Going events onebyone
        event1 = event_profile("residence")
        event1.setDate(2017, 1, 1)
        event4 = event_profile("birth")
        event4.setDate(2014, 1, 1)
        assert (checkDateConsistency([event1]))
        assert (checkDateConsistency([event4]))
        event1b = event_profile("burial")
        event1b.setDate(2017, 1, 1)
        assert (checkDateConsistency([event4, event1b]))
        event1d = event_profile("death")
        event1d.setDate(2017, 1, 1)
        event2 = event_profile("marriage")
        event2.setDate(2016, 1, 1)
        event3 = event_profile("baptism")
        event3.setDate(2015, 1, 1)
        assert (checkDateConsistency([event3, event2, event1d, event4]))

        event1bi = event_profile("birth")
        event1bi.setDate(2017, 1, 1)
        event4b = event_profile("burial")
        event4b.setDate(2014, 1, 1)

        assert (not checkDateConsistency([event1bi, event4b]))
        event1ba = event_profile("baptism")
        event1ba.setDate(2017, 1, 1)
        event4d = event_profile("death")
        event4d.setDate(2014, 1, 1)
        assert (not checkDateConsistency([event4d, event1ba]))
        event4bap = event_profile("baptism")
        event4bap.setDate(2014, 1, 1)
        assert (not checkDateConsistency([event4bap, event1bi]))
        #Checking that about dates are ok although the date2b is later than date4
        event2btest = event_profile("birth")
        event2btest.setDate(2014, 2, 1)
        event4test = event_profile("burial")
        event4test.setDate(2014, accuracy="ABOUT")
        event5test = event_profile("death")
        event5test.setDate(2014, accuracy="ABOUT")
        assert (checkDateConsistency([event2btest, event4test, event5test]))

        event4end = event_profile("death")
        event4end.setDate(2014, accuracy="ABOUT")
        event2bend = event_profile("burial")
        event2bend.setDate(2014, month=2, day=1, accuracy="BEFORE")
        #Test bug of burial and death
        assert (checkDateConsistency([event4end, event2bend]))
 def selfcheckDateConsistency(self, new_event):
     '''
     This function is a wrapper for calling the function of checking dates consistencies
     '''
     all_events = self.getEvents()
     all_events.append(new_event)
     return checkDateConsistency(all_events)
    def test_date_check(self):
        '''
        Test of the function for date check
        '''
        date1 = date(2017, 1, 1)
        date2 = date(2016, 1, 1)
        date3 = date(2015, 1, 1)
        date2b = date(2014, 2, 1)
        date4 = date(2014, 1, 1)
        assert (checkDateConsistency(None, date2b, None, None, None, None))
        assert (checkDateConsistency(date4, None, None, None, None, None))
        assert (checkDateConsistency(date4, None, None, None, None, date1))
        assert (checkDateConsistency(date4, None, date3, date2, date1, None))

        assert (not checkDateConsistency(date1, None, None, None, date4, None))
        assert (not checkDateConsistency(None, None, date1, None, date4, None))
        assert (not checkDateConsistency(date1, None, date4, None, None, None))
        #Checking that about dates are ok although the date2b is later than date4
        assert (checkDateConsistency(date2b,
                                     None,
                                     None,
                                     None,
                                     date4,
                                     date4,
                                     accuracy_death="ABOUT",
                                     accuracy_burial="ABOUT"))

        #Test bug of burial and death
        assert (checkDateConsistency(None,
                                     None,
                                     None,
                                     None,
                                     date4,
                                     date2b,
                                     accuracy_death="ABOUT",
                                     accuracy_burial="BEFORE"))
Exemple #4
0
 def selfcheckDateConsistency(self, dict_dates, dict_accuracy):
     #We set the dates received or taken from the profiles
     birth_date = dict_dates.get("birth_date", self.gen_data.get("birth_date", None) )
     residence_date = dict_dates.get("residence_date", self.gen_data.get("residence_date", None) )
     baptism_date = dict_dates.get("baptism_date", self.gen_data.get("baptism_date", None) )
     marriage_date = dict_dates.get("marriage_date", self.gen_data.get("marriage_date", None) )
     death_date = dict_dates.get("death_date", self.gen_data.get("death_date", None) )
     burial_date = dict_dates.get("burial_date", self.gen_data.get("burial_date", None) )
     #Similar attemp using accuracy
     accuracy_birth = dict_accuracy.get("accuracy_birth_date", self.gen_data.get("accuracy_birth_date", None) )
     accuracy_residence = dict_accuracy.get("accuracy_residence_date", self.gen_data.get("accuracy_residence_date", None) )
     accuracy_baptism = dict_accuracy.get("accuracy_baptism_date", self.gen_data.get("accuracy_baptism_date", None) )
     accuracy_marriage = dict_accuracy.get("accuracy_marriage_date", self.gen_data.get("accuracy_marriage_date", None) )
     accuracy_death = dict_accuracy.get("accuracy_death_date", self.gen_data.get("accuracy_death_date", None) )
     accuracy_burial = dict_accuracy.get("accuracy_burial_date", self.gen_data.get("accuracy_burial_date", None) )
     return checkDateConsistency(birth_date, residence_date, baptism_date,
                      marriage_date, death_date, burial_date,
                      accuracy_birth, accuracy_residence, accuracy_baptism,
                      accuracy_marriage , accuracy_death, accuracy_burial)
Exemple #5
0
birth_event.setDate(1900, 1, 1)
all_events.append(birth_event)
residence_event = event_profile("residence")
residence_event.setDate(1910, 1, 1)
all_events.append(residence_event)
baptism_event = event_profile("baptism")
baptism_event.setDate(1901, 1, 12)
all_events.append(baptism_event)
marriage_event = event_profile("marriage")
marriage_event.setDate(1930, 6, 1)
all_events.append(marriage_event)
death_event = event_profile("death")
death_event.setDate(1970, 1, 1)
all_events.append(death_event)
burial_event = event_profile("burial")
burial_event.setDate(1970, 1, 2)
all_events.append(burial_event)

#This function will provide a True if the dates are consistent (i.e. your are not getting baptised before being born of after dying)
checkDateConsistency(all_events)

#This function will provide the best date, taking 2 dates. In the following case, it will take reisdence date as being more accurate
getBestDate(date(1910, 2, 1), "AFTER", date(1910, 5, 1), "EXACT")

GENERIC_PLACE_STRING = "Portillo,Valladolid,Castile and Leon,Spain"
#This function provides a generic location in standard location format. It is using MAPBOX API in behind
get_formatted_location(GENERIC_PLACE_STRING)

my_name = "John Smith"
#It splits a given name into the name and surname. It checks the data with a database of names and surnames.
name, surname = get_name_surname_from_complete_name(my_name, language="en")
from datetime import date

birth_date = date(1900, 1, 1)
residence_date = date(1910, 1, 1)
baptism_date = date(1901, 1, 12)
marriage_date = date(1930, 6, 1)
death_date = date(1970, 1, 1)
burial_date = date(1970, 1, 2)

#This function will provide a True if the dates are consistent (i.e. your are not getting baptised before being born of after dying)
checkDateConsistency(birth_date,
                     residence_date,
                     baptism_date,
                     marriage_date,
                     death_date,
                     burial_date,
                     accuracy_birth="EXACT",
                     accuracy_residence="EXACT",
                     accuracy_baptism="EXACT",
                     accuracy_marriage="EXACT",
                     accuracy_death="EXACT",
                     accuracy_burial="EXACT")

#This function will provide the best date, taking 2 dates. In the following case, it will take reisdence date as being more accurate
getBestDate(birth_date, "AFTER", residence_date, "EXACT")

GENERIC_PLACE_STRING = "Portillo,Valladolid,Castile and Leon,Spain"
#This function provides a generic location in standard location format. It is using MAPBOX API in behind
get_formatted_location(GENERIC_PLACE_STRING)

my_name = "John Smith"
#It splits a given name into the name and surname. It checks the data with a database of names and surnames.