|
27 | 27 |
|
28 | 28 | addrtags = ('ADR1', 'ADR2', 'ADR3', 'CITY', 'STAE', 'POST', 'CTRY') |
29 | 29 |
|
| 30 | +maxage = 122 # https://en.wikipedia.org/wiki/List_of_the_verified_oldest_people |
| 31 | +maxmotherage = 66 # https://www.oldest.org/people/mothers/ |
| 32 | +maxfatherage = 93 # https://www.guinnessworldrecords.com/world-records/oldest-father- |
| 33 | +minmother = 11 |
| 34 | +minfather = 12 |
| 35 | + |
| 36 | + |
30 | 37 | thisgvOps = None |
31 | 38 |
|
32 | 39 | def getgdate (gstr): |
@@ -67,6 +74,54 @@ def getplace(gedcomtag : Record, placetag ="PLAC"): |
67 | 74 |
|
68 | 75 | return None |
69 | 76 |
|
| 77 | +def CheckAge(humans: Dict[str, Human], thisXrefID ): |
| 78 | + "" |
| 79 | + problems :list[str] = [] |
| 80 | + if humans[thisXrefID]: |
| 81 | + thishuman = humans[thisXrefID] |
| 82 | + born = None |
| 83 | + died = None |
| 84 | + if thishuman.birth: |
| 85 | + born = thishuman.birth.whenyearnum() |
| 86 | + if thishuman.death: |
| 87 | + died = thishuman.death.whenyearnum() |
| 88 | + if born and died: |
| 89 | + if died < born: |
| 90 | + problems.append("Died before Born") |
| 91 | + if died - born > maxage: |
| 92 | + problems.append(f"Too old {died - born} > {maxage}") |
| 93 | + if thishuman.children: |
| 94 | + for childId in thishuman.children: |
| 95 | + if humans[childId]: |
| 96 | + child = humans[childId] |
| 97 | + if child.birth and child.birth.whenyearnum(): |
| 98 | + if born: |
| 99 | + parentatage = child.birth.whenyearnum() - born |
| 100 | + if thishuman.sex == "F": |
| 101 | + if parentatage > maxmotherage: |
| 102 | + problems.append(f"Mother too old {parentatage} > {maxmotherage} for {child.name} [{child.xref_id}]") |
| 103 | + if parentatage < minmother: |
| 104 | + problems.append(f"Mother too young {parentatage} < {minmother} for {child.name} [{child.xref_id}]") |
| 105 | + |
| 106 | + if died and died < parentatage: |
| 107 | + problems.append(f"Mother after death for {child.name} [{child.xref_id}]") |
| 108 | + elif thishuman.sex == "M": |
| 109 | + if parentatage > maxfatherage: |
| 110 | + problems.append(f"Father too old {parentatage} > {maxfatherage} for {child.name} [{child.xref_id}]") |
| 111 | + if parentatage < minfather: |
| 112 | + problems.append(f"Father too young {parentatage} < {minfather} for {child.name} [{child.xref_id}]") |
| 113 | + |
| 114 | + # Birth after father dies within a year |
| 115 | + if died and died+1 < parentatage: |
| 116 | + problems.append(f"Father after death for {child.name} [{child.xref_id}]") |
| 117 | + else: |
| 118 | + if parentatage > max(maxfatherage,maxmotherage): |
| 119 | + problems.append(f"Parent too old {parentatage} > {max(maxfatherage,maxmotherage)} for {child.name} [{child.xref_id}]") |
| 120 | + if parentatage < min(minmother, minfather): |
| 121 | + problems.append(f"Parent too young {parentatage} < {min(maxfatherage,maxmotherage)} for {child.name} [{child.xref_id}]") |
| 122 | + |
| 123 | + return problems |
| 124 | + |
70 | 125 | class GetPosFromTag: |
71 | 126 | """ build an LifeEvent, but also return the other attributes """ |
72 | 127 | def __init__(self, gedcomtag : Record, tag : str, placetag ="PLAC"): |
@@ -284,7 +339,7 @@ def __create_human(record: Record) -> Human: |
284 | 339 | @staticmethod |
285 | 340 | def __create_humans(records0) -> Dict[str, Human]: |
286 | 341 | global thisgvOps |
287 | | - humans = dict() |
| 342 | + humans : Dict[str, Human] = dict() |
288 | 343 | thisgvOps.step("Reading GED", target=(thisgvOps.totalGEDpeople+thisgvOps.totalGEDfamily)) |
289 | 344 | for record in records0("INDI"): |
290 | 345 | if thisgvOps.ShouldStop(): |
@@ -323,9 +378,10 @@ def __create_humans(records0) -> Dict[str, Human]: |
323 | 378 | continue |
324 | 379 | if husband: |
325 | 380 | humans[chil.xref_id].father = husband.xref_id |
326 | | - |
| 381 | + humans[husband.xref_id].children.append(chil.xref_id) |
327 | 382 | if wife: |
328 | 383 | humans[chil.xref_id].mother = wife.xref_id |
| 384 | + humans[wife.xref_id].children.append(chil.xref_id) |
329 | 385 | else: |
330 | 386 | _log.warning("Family has missing INDI record for one of the CHIL: %s", record.xref_id) |
331 | 387 |
|
|
0 commit comments