def output():
    inds, fams = get_inds_fams('res/test_all_user_stories.ged')
    print_inds(inds)
    print_fams(fams)
    # Sprint1
    # Danping Cai
    print(dates_before_current_date(inds, fams))
    print(birth_before_marriage(inds, fams))
    # Zihao Kang
    print(birth_after_death_of_parents(fams, inds))
    print(marriage_after_14(fams, inds))
    # Siteng Fan
    print(', '.join(no_marries_to_children(inds, fams)))
    print(', '.join(siblings_not_marry(inds, fams)))
    # Yuning Sun
    print(', '.join(include_individual_ages(inds)))
    print(', '.join(corresponding_entries(inds, fams)))
    # Sprint2
    # Danping Cai
    print(','.join(birth_before_death(inds)))
    print(','.join(marriage_before_divorce(fams)))
    # Zihao Kang
    print(parents_not_too_old(fams, inds))
    print(too_many_siblings(fams, inds))
    # Siteng Fan
    print(','.join(first_cousin_should_not_marry(inds, fams)))
    print(','.join(aunts_and_uncles(inds, fams)))
    # Yuning Sun
    try:
        inds, fams = get_inds_fams('res/US42_1.ged')
        for ind in inds:
            check_date_valid(ind, 'ind')
        for fam in fams:
            check_date_valid(fam, 'fam')
    except ValueError as e:
        print(e)
    # Sprint3
    # Danping Cai
    print(','.join(marriage_before_death(inds, fams)))
    print(','.join(divorce_before_death(inds, fams)))
    # Siteng Fan
    print(','.join(correct_gender(inds, fams)))
    print(','.join(unique_id(inds, fams)))
    # Zihao Kang
    print(multiple_births(fams, inds))
    print(male_last_names(fams, inds))
    # Yuning Sun
    print(order_sibling_by_age(inds, fams))
    print(list_deceased(inds))
Exemplo n.º 2
0
 def test_US01(self):
     inds, fams = get_inds_fams('res/US01_02.ged')
     self.assertEqual(dates_before_current_date(inds, fams), [
         'ERROR: INDIVIDUAL: US01: 82: @I7@: Death 2022-09-14 00:00:00 day is after '
         'today',
         'ERROR: FAMILY: US01: 133: @F1@: Divorce date 2022-08-12 00:00:00 is after '
         'today'
     ])
Exemplo n.º 3
0
    def test_US08(self):
        inds, fams = get_inds_fams('res/US08.ged')
        self.assertEqual(
            birth_before_marriage_of_parents(inds, fams),
            """ERROR: INDIVIDUAL: US08: line20: @I1@: Child birthday 12 MAY 1993 before parents' marriage date 12 DEC 1993
ERROR: INDIVIDUAL: US08: line130: @I12@: Child birthday 3 AUG 2003 is more than 9 months after parents' divorce date 12 DEC 1993
ERROR: INDIVIDUAL: US08: line31: @I2@: Child birthday 19 DEC 1969 before parents' marriage date 7 JUL 1972
ERROR: INDIVIDUAL: US08: line42: @I3@: Child birthday 3 MAR 1970 before parents' marriage date 13 MAR 1974
""")
Exemplo n.º 4
0
 def test_true(self):
     inds, fams = get_inds_fams('res/valid.ged')
     self.assertEqual(dates_before_current_date(inds, fams), None)
     self.assertEqual(birth_before_marriage(inds, fams), None)
     self.assertEqual(birth_after_death_of_parents(fams, inds), None)
     self.assertEqual(marriage_after_14(fams, inds), None)
     self.assertEqual(no_marries_to_children(inds, fams), None)
     self.assertEqual(siblings_not_marry(inds, fams), None)
     self.assertEqual(corresponding_entries(inds, fams), None)
     self.assertEqual(include_individual_ages(inds), [])
Exemplo n.º 5
0
def reject_illegitimate_dates():
    """
    All dates should be legitimate dates for the months specified (e.g., 2/30/2015 is not legitimate)
    @return:
    """
    try:
        # inds, fams = get_inds_fams('../res/US42.ged')
        inds, fams = get_inds_fams('../res/US42_1.ged')
        for ind in inds:
            check_date_valid(ind, 'ind')
        for fam in fams:
            check_date_valid(fam, 'fam')
    except ValueError as e:
        print(e)
def output():
    inds, fams = get_inds_fams('res/test_all_user_stories.ged')
    print_inds(inds)
    print_fams(fams)

    # Danping Cai
    print(dates_before_current_date(inds, fams))
    print(birth_before_marriage(inds, fams))
    # Zihao Kang
    print(birth_after_death_of_parents(fams, inds))
    print(marriage_after_14(fams, inds))
    # Siteng Fan
    print(', '.join(no_marries_to_children(inds, fams)))
    print(', '.join(siblings_not_marry(inds, fams)))
    # Yuning Sun
    print(', '.join(include_individual_ages(inds)))
    print(', '.join(corresponding_entries(inds, fams)))
Exemplo n.º 7
0
 def test_US15(self):
     inds, fams = geddata.get_inds_fams('res/US15.ged')
     self.assertEqual(too_many_siblings(fams, inds), 'ERROR: line 151 US15: too many siblings!')
Exemplo n.º 8
0
 def test_US12(self):
     inds, fams = geddata.get_inds_fams('res/US12.ged')
     self.assertEqual(parents_not_too_old(fams, inds), 'ERROR: line 31 US12: Parents too old!')
Exemplo n.º 9
0
 def test_US10(self):
     inds, fams = geddata.get_inds_fams('res/US10.ged')
     self.assertEqual(marriage_after_14(fams, inds), 'ERROR: line: 156 US10: Parents less than 14 years old!')
Exemplo n.º 10
0
 def test_US09(self):
     inds, fams = geddata.get_inds_fams('res/US09.ged')
     self.assertEqual(birth_after_death_of_parents(fams, inds),
                      'ERROR: INDIVIDUAL: LINE: 42: US09: Child birth after parent death!')
Exemplo n.º 11
0
 def test_US11(self):
     inds, fams = get_inds_fams('res/US11.ged')
     self.assertEqual(
         no_bigamy(fams, inds),
         'ERROR: INDIVIDUAL: line24 US11: Marriage should not occur during marriage to another spouse!'
     )
Exemplo n.º 12
0
 def test_US23(self):
     inds, fams = get_inds_fams('res/US23.ged')
     self.assertEqual(unique_name_and_birth(inds, fams), [
         'ERROR: INDIVIDUAL: US23: line140 and line 130: these two guys have same name and birthday'
     ])
Exemplo n.º 13
0
 def test_US42(self):
     with self.assertRaises(ValueError) as e:
         inds, fams = geddata.get_inds_fams('res/US42_1.ged')
Exemplo n.º 14
0
 def test_US32(self):
     inds, fams = get_inds_fams('res/US32.ged')
     mbl = list_multiple_births(inds, fams)
     id_list = sorted([ind['id'].value for ind in mbl])
     self.assertEqual(id_list, ['@I12@', '@I4@'])
Exemplo n.º 15
0
 def test_US33(self):
     inds, fams = get_inds_fams('res/US33.ged')
     lo = list_orphans(inds, fams)
     id_list = sorted([ind['id'].value for ind in lo])
     self.assertEqual(id_list, ['@I47@'])
Exemplo n.º 16
0
 def test_US31(self):
     inds, fams = get_inds_fams('res/US31.ged')
     lsl = list_living_single(inds, fams)
     id_list = sorted([ind['id'].value for ind in lsl])
     self.assertEqual(id_list, ['@I12@'])
Exemplo n.º 17
0
 def test_US30(self):
     inds, fams = get_inds_fams('res/US30.ged')
     lml = list_living_married(inds, fams)
     id_list = sorted([ind['id'].value for ind in lml])
     self.assertEqual(id_list, ['@I2@', '@I3@', '@I6@'])
Exemplo n.º 18
0
 def test_US24(self):
     inds, fams = get_inds_fams('res/US24.ged')
     self.assertEqual(unique_families_by_spouse(inds, fams), [
         'ERROR: INDIVIDUAL: US24: line196 and line 190: these two families have same spouses and marry date'
     ])
Exemplo n.º 19
0
 def test_US19(self):
     inds, fams = geddata.get_inds_fams('res/US19_20.ged')
     self.assertEqual(first_cousin_should_not_marry(inds, fams),
                      ['ERROR: FAMILY: US19: line139: Couple Bingbao /Xia/ and Xue /Xia/ are first cousins'])
Exemplo n.º 20
0
    return record


def unique_id(inds, fams):
    """
    every id must unique
    :param inds:
    :param fams:
    :return: list of error inforamtion
    """
    record = []
    for ind in inds:
        for ind2 in inds[inds.index(ind) + 1:]:
            if ind['id'].value == ind2['id'].value:
                record.append(
                    f"ERROR: INDIVIDUAL: US22: line{ind['id'].line} and line{ind2['id'].line}: These 2 individuals have same id"
                )
    for fam in fams:
        for fam2 in fams[fams.index(fam) + 1:]:
            if fam['id'].value == fam2['id'].value:
                record.append(
                    f"ERROR: FAMILY: US22: line{fam['id'].line} and line{fam2['id'].line}: These 2 families have same id"
                )
    return record


if __name__ == '__main__':
    inds, fams = get_inds_fams('../res/US22.ged')
    print(correct_gender(inds, fams))
    print(unique_id(inds, fams))
Exemplo n.º 21
0
 def test_US20(self):
     inds, fams = geddata.get_inds_fams('res/US19_20.ged')
     self.assertEqual(aunts_and_uncles(inds, fams),
                      ['ERROR: FAMILY: US20: line186: Yu /Xia/ marries to his aunt Nanhai /Xia/'])
Exemplo n.º 22
0
    return results


def birth_before_marriage_of_parents(inds, fams):
    results = ''
    for fam in fams:
        marr = fam['marr']
        marr_date = datetime.datetime.strptime(marr.value, '%d %b %Y')
        chils = fam['chil']
        for chil_id in chils:
            chil = get_ind_by_id(chil_id, inds)
            if 'birt' not in chil.__dict__.keys():
                continue
            birth_date = chil['birt'].value
            birth_date = datetime.datetime.strptime(birth_date, '%d %b %Y')
            if birth_date < marr_date:
                results += f"ERROR: INDIVIDUAL: US08: line{chil['birt'].line}: {chil['id'].value}: Child birthday {chil['birt'].value} before parents' marriage date {marr.value}\n"
            if 'div' in fam.__dict__.keys():
                div = fam['div']
                div_date = datetime.datetime.strptime(div.value, '%d %b %Y')
                if (birth_date - div_date).days > 270:
                    results += f"ERROR: INDIVIDUAL: US08: line{chil['birt'].line}: {chil['id'].value}: Child birthday {chil['birt'].value} is more than 9 months after parents' divorce date {marr.value}\n"
    return results


if __name__ == '__main__':
    inds, fams = get_inds_fams('../res/test_all_user_stories.ged')
    print(less_than_150_years_old(inds))
    print(birth_before_marriage_of_parents(inds, fams))
    print()
Exemplo n.º 23
0
def output():
    inds, fams = get_inds_fams('res/test_all_user_stories.ged')
    print_inds(inds)
    print_fams(fams)
    # Danping Cai
    print('\n'.join(dates_before_current_date(inds, fams)))
    print(birth_before_marriage(inds, fams))
    # Danping Cai
    print(','.join(birth_before_death(inds)))
    print(','.join(marriage_before_divorce(fams)))
    # Danping Cai
    print(','.join(marriage_before_death(inds, fams)))
    print(','.join(divorce_before_death(inds, fams)))
    # Sprint 4
    print(less_than_150_years_old(inds))
    print(birth_before_marriage_of_parents(inds, fams))
    # Zihao Kang
    print(birth_after_death_of_parents(fams, inds))
    print(marriage_after_14(fams, inds))
    print(no_bigamy(fams, inds))
    # Zihao Kang
    print(parents_not_too_old(fams, inds))
    print(siblings_spacing(fams, inds))
    print(multiple_births(fams, inds))
    print(too_many_siblings(fams, inds))
    # Zihao Kang
    print(male_last_names(fams, inds))
    # Sprint 4
    # Siteng Fan
    print('\n'.join(no_marries_to_children(inds, fams)))
    print('\n'.join(siblings_not_marry(inds, fams)))
    # Siteng Fan
    print('\n'.join(first_cousin_should_not_marry(inds, fams)))
    print('\n'.join(aunts_and_uncles(inds, fams)))
    # Siteng Fan
    print('\n'.join(correct_gender(inds, fams)))
    print('\n'.join(unique_id(inds, fams)))
    # Sprint 4
    print('\n'.join(unique_name_and_birth(inds, fams)))
    print('\n'.join(unique_families_by_spouse(inds, fams)))
    # Yuning Sun
    print('\n'.join(corresponding_entries(inds, fams)))
    print('\n'.join(include_individual_ages(inds)))
    print('US28 List ordered sibling by age')
    ordered_fams = order_sibling_by_age(inds, fams)
    print_fams(ordered_fams)
    print('US29 List deceased individual')
    deceased_inds = list_deceased(inds)
    print_inds(deceased_inds)
    print('US30 List living married')
    lml = list_living_married(inds, fams)
    print_inds(lml)
    print('US31 List Living single')
    lsl = list_living_single(inds, fams)
    print_inds(lsl)
    print('US32 List multiple births')
    mbl = list_multiple_births(inds, fams)
    print_inds(mbl)
    print('US33 List orphans')
    lo = list_orphans(inds, fams)
    print_inds(lo)
    try:
        inds, fams = get_inds_fams('res/US42_1.ged')
        for ind in inds:
            check_date_valid(ind, 'ind')
        for fam in fams:
            check_date_valid(fam, 'fam')
    except ValueError as e:
        print(e)
Exemplo n.º 24
0
 def test_US13(self):
     inds, fams = get_inds_fams('res/US13.ged')
     self.assertEqual(
         siblings_spacing(fams, inds),
         'ERROR: FAMILY: @F3@ US13: Birth dates of siblings should be more than 8 months apart or less than 2 days apart!'
     )
Exemplo n.º 25
0
                return f"ERROR: INDIVIDUAL: LINE: {child_ind['birt'].line}: US09: Child birth after parent death!"


def marriage_after_14(fams, inds):
    """
    US10: Marriage date should be at least 14 years after birth date for a person
    """
    for fam in fams:
        father_ind = get_ind_by_id(fam["husb"], inds)
        if 'birt' not in father_ind.__dict__.keys():
            continue
        fa_year_birth = datetime.datetime.strptime(str(father_ind['birt']), '%d %b %Y').year

        mother_ind = get_ind_by_id(fam["wife"], inds)
        if 'birt' not in mother_ind.__dict__.keys():
            continue
        ma_year_birth = datetime.datetime.strptime(str(mother_ind['birt']), '%d %b %Y').year

        marr_date = datetime.datetime.strptime(str(fam['marr']), '%d %b %Y').year

        if (marr_date - fa_year_birth) < 14 or (marr_date - ma_year_birth) < 14:
            return f"ERROR: FAMILY: LINE: {fam['marr'].line}: US10: Parents less than 14 years old!"


if __name__ == '__main__':
    inds, fams = geddata.get_inds_fams('../res/test_sprint2_all.ged')

    print(birth_after_death_of_parents(fams, inds))

    print(marriage_after_14(fams, inds))
Exemplo n.º 26
0
def male_last_names(fams, inds):
    """
    US16: Male last names
    All male members of a family should have the same last name
    """
    for fam in fams:
        father_ind = get_ind_by_id(fam["husb"], inds)
        if 'sex' not in father_ind.__dict__.keys():
            continue
        fa_name = str(father_ind['name'])
        for child_id in fam['chil']:
            # print('child:')
            # print(child_id)
            child_ind = get_ind_by_id(child_id, inds)
            ch_name = str(child_ind['name'])
            ch_gender = str(child_ind['sex'])
            # print(str(ch_name)[-3:])
            # print(ch_gender == 'M')
            if 'sex' not in child_ind.__dict__.keys():
                continue
            if ch_gender == 'M' and fa_name[-3:] != ch_name[-3:]:
                return f"ERROR: FAMILY: LINE: {child_ind['name'].line} US16: All male members of a family should have the same last name!"


if __name__ == '__main__':
    inds, fams = geddata.get_inds_fams('../res/US16.ged')
    print(male_last_names(fams, inds))
    inds, fams = geddata.get_inds_fams('../res/US14.ged')
    print(multiple_births(fams, inds))
Exemplo n.º 27
0
def main():
    inds, fams = get_inds_fams('../res/test_sprint2_all.ged')
    print(dates_before_current_date(inds, fams))
    print(birth_before_marriage(inds, fams))
Exemplo n.º 28
0
 def test_US03(self):
     inds, fams = geddata.get_inds_fams('res/US03.ged')
     self.assertEqual(birth_before_death(inds),
                      ['ERROR: INDIVIDUAL: US03: 80: @I7@: Birthday 1945-08-11 00:00:00 is after death.'])
Exemplo n.º 29
0
            child_ind = get_ind_by_id(child_id, inds)
            child_birth_date = datetime.datetime.strptime(
                str(child_ind['birt']), '%d %b %Y')
            # print(child_birth_date)
            child_birth_date_list.append(child_birth_date)
            # print(child_birth_date_list)
        for date1 in child_birth_date_list:
            for date2 in child_birth_date_list:
                time_diff = date2 - date1
                if datetime.timedelta(
                        days=240) > time_diff > datetime.timedelta(days=2):
                    return f"ERROR: FAMILY: {fam['id']} US13: Birth dates of siblings should be more than 8 months apart or less than 2 days apart!"


if __name__ == '__main__':
    inds, fams = geddata.get_inds_fams('../res/US11.ged')
    print(no_bigamy(fams, inds))
    inds, fams = geddata.get_inds_fams('../res/test_all_user_stories.ged')
    print(siblings_spacing(fams, inds))
    # print(siblings_spacing(fams, inds))
    # child_birth_date_list = []
    # for fam in fams:
    #     for child_id in fam['chil']:
    #         child_ind = get_ind_by_id(child_id, inds)
    #         child_birth_date = datetime.datetime.strptime(str(child_ind['birt']), '%d %b %Y')
    #         print(child_birth_date)
    #         child_birth_date_list.append(child_birth_date)
    #         print(child_birth_date_list)
    #         for date1 in child_birth_date_list:
    #             for date2 in child_birth_date_list:
    #                 time_diff = date2 - date1
Exemplo n.º 30
0
 def test_US04(self):
     inds, fams = geddata.get_inds_fams('res/US04.ged')
     self.assertEqual(marriage_before_divorce(fams),
                      ['ERROR: FAMILY: US04: 133: @F1@: Marriage should occur before divorce of spouses'])