def test_getting_a_date(self):
     '''
     Test the module for merging dates
     '''
     date1 = date(2018,1,1)
     date2 = date(2016,1,1)
     date3, accuracy3 = getBestDate(date1, "EXACT", date2, "EXACT")
     assert(date3 == date1)
     assert(accuracy3 == "EXACT")
     
     date4, accuracy4 = getBestDate(date1, "AFTER", date2, "EXACT")
     assert(date4 == date2)
     assert(accuracy4 == "EXACT")
     
     date5, accuracy5 = getBestDate(date1, "AFTER", date2, "BEFORE")
     assert(date5 == date1)
     assert(accuracy5 == "AFTER")
     
     date6, accuracy6 = getBestDate(date1, "ABOUT", date2, "BEFORE")
     assert(date6 == date2)
     assert(accuracy6 == "BEFORE")
     
     date7, accuracy7 = getBestDate(date1, "ABOUT", date2, "ABOUT")
     assert(date7 == date(2017,1,1))
     assert(accuracy7 == "ABOUT")
     
     date8, accuracy8 = getBestDate(date1, "LALALA", date2, "ABOUT")
     assert(date8 == None)
     assert(accuracy8 == None)
Exemple #2
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")
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.
name, surname = get_name_surname_from_complete_name(my_name, language="en")