gedcom-x 0.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gedcom_x-0.5.dist-info/METADATA +17 -0
- gedcom_x-0.5.dist-info/RECORD +37 -0
- gedcom_x-0.5.dist-info/WHEEL +5 -0
- gedcom_x-0.5.dist-info/top_level.txt +1 -0
- gedcomx/Address.py +100 -0
- gedcomx/Agent.py +83 -0
- gedcomx/Attribution.py +116 -0
- gedcomx/Conclusion.py +137 -0
- gedcomx/Coverage.py +26 -0
- gedcomx/Date.py +29 -0
- gedcomx/Document.py +42 -0
- gedcomx/Event.py +195 -0
- gedcomx/EvidenceReference.py +11 -0
- gedcomx/Fact.py +462 -0
- gedcomx/Gedcom.py +345 -0
- gedcomx/GedcomX.py +1105 -0
- gedcomx/Gender.py +48 -0
- gedcomx/Group.py +37 -0
- gedcomx/Identifier.py +89 -0
- gedcomx/Name.py +241 -0
- gedcomx/Note.py +65 -0
- gedcomx/OnlineAccount.py +10 -0
- gedcomx/Person.py +178 -0
- gedcomx/PlaceDescription.py +47 -0
- gedcomx/PlaceReference.py +31 -0
- gedcomx/Qualifier.py +27 -0
- gedcomx/Relationship.py +116 -0
- gedcomx/Serialization.py +37 -0
- gedcomx/SourceCitation.py +20 -0
- gedcomx/SourceDescription.py +241 -0
- gedcomx/SourceReference.py +168 -0
- gedcomx/Subject.py +73 -0
- gedcomx/TextValue.py +34 -0
- gedcomx/TopLevelTypeCollection.py +47 -0
- gedcomx/URI.py +70 -0
- gedcomx/_Resource.py +11 -0
- gedcomx/__init__.py +39 -0
gedcomx/Event.py
ADDED
@@ -0,0 +1,195 @@
|
|
1
|
+
from enum import Enum
|
2
|
+
from typing import List, Optional
|
3
|
+
|
4
|
+
from gedcomx.EvidenceReference import EvidenceReference
|
5
|
+
from gedcomx.Identifier import Identifier
|
6
|
+
|
7
|
+
from .Attribution import Attribution
|
8
|
+
from .Conclusion import Conclusion, ConfidenceLevel
|
9
|
+
from .Date import Date
|
10
|
+
from .Note import Note
|
11
|
+
from .PlaceReference import PlaceReference
|
12
|
+
from .SourceReference import SourceReference
|
13
|
+
from .Subject import Subject
|
14
|
+
from .URI import URI
|
15
|
+
|
16
|
+
class EventRoleType(Enum):
|
17
|
+
Principal = "http://gedcomx.org/Principal"
|
18
|
+
Participant = "http://gedcomx.org/Participant"
|
19
|
+
Official = "http://gedcomx.org/Official"
|
20
|
+
Witness = "http://gedcomx.org/Witness"
|
21
|
+
|
22
|
+
@property
|
23
|
+
def description(self):
|
24
|
+
descriptions = {
|
25
|
+
EventRole.Principal: "The person is the principal person of the event. For example, the principal of a birth event is the person that was born.",
|
26
|
+
EventRole.Participant: "A participant in the event.",
|
27
|
+
EventRole.Official: "A person officiating the event.",
|
28
|
+
EventRole.Witness: "A witness of the event."
|
29
|
+
}
|
30
|
+
return descriptions.get(self, "No description available.")
|
31
|
+
|
32
|
+
class EventRole(Conclusion):
|
33
|
+
identifier = 'http://gedcomx.org/v1/EventRole'
|
34
|
+
version = 'http://gedcomx.org/conceptual-model/v1'
|
35
|
+
|
36
|
+
def __init__(self,
|
37
|
+
id: Optional[str] = None,
|
38
|
+
lang: Optional[str] = 'en',
|
39
|
+
sources: Optional[List[SourceReference]] = [],
|
40
|
+
analysis: Optional[URI] = None,
|
41
|
+
notes: Optional[List[Note]] = [],
|
42
|
+
confidence: Optional[ConfidenceLevel] = None,
|
43
|
+
attribution: Optional[Attribution] = None,
|
44
|
+
person: URI = None,
|
45
|
+
type: Optional[EventRoleType] = None,
|
46
|
+
details: Optional[str] = None) -> None:
|
47
|
+
super().__init__(id, lang, sources, analysis, notes, confidence, attribution)
|
48
|
+
self.person = person
|
49
|
+
self.type = type
|
50
|
+
self.details = details
|
51
|
+
|
52
|
+
class EventType(Enum):
|
53
|
+
Adoption = "http://gedcomx.org/Adoption"
|
54
|
+
AdultChristening = "http://gedcomx.org/AdultChristening"
|
55
|
+
Annulment = "http://gedcomx.org/Annulment"
|
56
|
+
Baptism = "http://gedcomx.org/Baptism"
|
57
|
+
BarMitzvah = "http://gedcomx.org/BarMitzvah"
|
58
|
+
BatMitzvah = "http://gedcomx.org/BatMitzvah"
|
59
|
+
Birth = "http://gedcomx.org/Birth"
|
60
|
+
Blessing = "http://gedcomx.org/Blessing"
|
61
|
+
Burial = "http://gedcomx.org/Burial"
|
62
|
+
Census = "http://gedcomx.org/Census"
|
63
|
+
Christening = "http://gedcomx.org/Christening"
|
64
|
+
Circumcision = "http://gedcomx.org/Circumcision"
|
65
|
+
Confirmation = "http://gedcomx.org/Confirmation"
|
66
|
+
Cremation = "http://gedcomx.org/Cremation"
|
67
|
+
Death = "http://gedcomx.org/Death"
|
68
|
+
Divorce = "http://gedcomx.org/Divorce"
|
69
|
+
DivorceFiling = "http://gedcomx.org/DivorceFiling"
|
70
|
+
Education = "http://gedcomx.org/Education"
|
71
|
+
Engagement = "http://gedcomx.org/Engagement"
|
72
|
+
Emigration = "http://gedcomx.org/Emigration"
|
73
|
+
Excommunication = "http://gedcomx.org/Excommunication"
|
74
|
+
FirstCommunion = "http://gedcomx.org/FirstCommunion"
|
75
|
+
Funeral = "http://gedcomx.org/Funeral"
|
76
|
+
Immigration = "http://gedcomx.org/Immigration"
|
77
|
+
LandTransaction = "http://gedcomx.org/LandTransaction"
|
78
|
+
Marriage = "http://gedcomx.org/Marriage"
|
79
|
+
MilitaryAward = "http://gedcomx.org/MilitaryAward"
|
80
|
+
MilitaryDischarge = "http://gedcomx.org/MilitaryDischarge"
|
81
|
+
Mission = "http://gedcomx.org/Mission"
|
82
|
+
MoveFrom = "http://gedcomx.org/MoveFrom"
|
83
|
+
MoveTo = "http://gedcomx.org/MoveTo"
|
84
|
+
Naturalization = "http://gedcomx.org/Naturalization"
|
85
|
+
Ordination = "http://gedcomx.org/Ordination"
|
86
|
+
Retirement = "http://gedcomx.org/Retirement"
|
87
|
+
|
88
|
+
@property
|
89
|
+
def description(self):
|
90
|
+
descriptions = {
|
91
|
+
EventType.Adoption: "An adoption event.",
|
92
|
+
EventType.AdultChristening: "An adult christening event.",
|
93
|
+
EventType.Annulment: "An annulment event of a marriage.",
|
94
|
+
EventType.Baptism: "A baptism event.",
|
95
|
+
EventType.BarMitzvah: "A bar mitzvah event.",
|
96
|
+
EventType.BatMitzvah: "A bat mitzvah event.",
|
97
|
+
EventType.Birth: "A birth event.",
|
98
|
+
EventType.Blessing: "An official blessing event, such as at the hands of a clergy member or at another religious rite.",
|
99
|
+
EventType.Burial: "A burial event.",
|
100
|
+
EventType.Census: "A census event.",
|
101
|
+
EventType.Christening: "A christening event at birth. Note: use AdultChristening for a christening event as an adult.",
|
102
|
+
EventType.Circumcision: "A circumcision event.",
|
103
|
+
EventType.Confirmation: "A confirmation event (or other rite of initiation) in a church or religion.",
|
104
|
+
EventType.Cremation: "A cremation event after death.",
|
105
|
+
EventType.Death: "A death event.",
|
106
|
+
EventType.Divorce: "A divorce event.",
|
107
|
+
EventType.DivorceFiling: "A divorce filing event.",
|
108
|
+
EventType.Education: "An education or educational achievement event (e.g., diploma, graduation, scholarship, etc.).",
|
109
|
+
EventType.Engagement: "An engagement to be married event.",
|
110
|
+
EventType.Emigration: "An emigration event.",
|
111
|
+
EventType.Excommunication: "An excommunication event from a church.",
|
112
|
+
EventType.FirstCommunion: "A first communion event.",
|
113
|
+
EventType.Funeral: "A funeral event.",
|
114
|
+
EventType.Immigration: "An immigration event.",
|
115
|
+
EventType.LandTransaction: "A land transaction event.",
|
116
|
+
EventType.Marriage: "A marriage event.",
|
117
|
+
EventType.MilitaryAward: "A military award event.",
|
118
|
+
EventType.MilitaryDischarge: "A military discharge event.",
|
119
|
+
EventType.Mission: "A mission event.",
|
120
|
+
EventType.MoveFrom: "An event of a move (i.e., change of residence) from a location.",
|
121
|
+
EventType.MoveTo: "An event of a move (i.e., change of residence) to a location.",
|
122
|
+
EventType.Naturalization: "A naturalization event (i.e., acquisition of citizenship and nationality).",
|
123
|
+
EventType.Ordination: "An ordination event.",
|
124
|
+
EventType.Retirement: "A retirement event."
|
125
|
+
}
|
126
|
+
return descriptions.get(self, "No description available.")
|
127
|
+
|
128
|
+
@staticmethod
|
129
|
+
def guess(description):
|
130
|
+
keywords_to_event_type = {
|
131
|
+
"adoption": EventType.Adoption,
|
132
|
+
"christening": EventType.Christening,
|
133
|
+
"annulment": EventType.Annulment,
|
134
|
+
"baptism": EventType.Baptism,
|
135
|
+
"bar mitzvah": EventType.BarMitzvah,
|
136
|
+
"bat mitzvah": EventType.BatMitzvah,
|
137
|
+
"birth": EventType.Birth,
|
138
|
+
"blessing": EventType.Blessing,
|
139
|
+
"burial": EventType.Burial,
|
140
|
+
"census": EventType.Census,
|
141
|
+
"circumcision": EventType.Circumcision,
|
142
|
+
"confirmation": EventType.Confirmation,
|
143
|
+
"cremation": EventType.Cremation,
|
144
|
+
"death": EventType.Death,
|
145
|
+
"divorce": EventType.Divorce,
|
146
|
+
"divorce filing": EventType.DivorceFiling,
|
147
|
+
"education": EventType.Education,
|
148
|
+
"engagement": EventType.Engagement,
|
149
|
+
"emigration": EventType.Emigration,
|
150
|
+
"excommunication": EventType.Excommunication,
|
151
|
+
"first communion": EventType.FirstCommunion,
|
152
|
+
"funeral": EventType.Funeral,
|
153
|
+
"arrival": EventType.Immigration,
|
154
|
+
"immigration": EventType.Immigration,
|
155
|
+
"land transaction": EventType.LandTransaction,
|
156
|
+
"marriage": EventType.Marriage,
|
157
|
+
"military award": EventType.MilitaryAward,
|
158
|
+
"military discharge": EventType.MilitaryDischarge,
|
159
|
+
"mission": EventType.Mission,
|
160
|
+
"move from": EventType.MoveFrom,
|
161
|
+
"move to": EventType.MoveTo,
|
162
|
+
"naturalization": EventType.Naturalization,
|
163
|
+
"ordination": EventType.Ordination,
|
164
|
+
"retirement": EventType.Retirement,
|
165
|
+
}
|
166
|
+
|
167
|
+
description_lower = description.lower()
|
168
|
+
|
169
|
+
for keyword, event_type in keywords_to_event_type.items():
|
170
|
+
if keyword in description_lower:
|
171
|
+
return event_type
|
172
|
+
|
173
|
+
return None # Default to UNKNOWN if no match is found
|
174
|
+
|
175
|
+
class Event(Subject):
|
176
|
+
identifier = 'http://gedcomx.org/v1/Event'
|
177
|
+
version = 'http://gedcomx.org/conceptual-model/v1'
|
178
|
+
|
179
|
+
def __init__(self,
|
180
|
+
id: Optional[str] = None,
|
181
|
+
lang: Optional[str] = 'en',
|
182
|
+
sources: Optional[List[SourceReference]] = [],
|
183
|
+
analysis: Optional[URI] = None,
|
184
|
+
notes: Optional[List[Note]] = [],
|
185
|
+
confidence: Optional[ConfidenceLevel] = None,
|
186
|
+
attribution: Optional[Attribution] = None,
|
187
|
+
extracted: Optional[bool] = False,
|
188
|
+
evidence: Optional[List[EvidenceReference]] = [],
|
189
|
+
media: Optional[List[SourceReference]] = [],
|
190
|
+
identifiers: Optional[List[Identifier]] = [],
|
191
|
+
type: Optional[EventType] = None,
|
192
|
+
date: Optional[Date] = None,
|
193
|
+
place: Optional[PlaceReference] = None,
|
194
|
+
roles: Optional[List[EventRole]] = []) -> None:
|
195
|
+
super().__init__(id, lang, sources, analysis, notes, confidence, attribution, extracted, evidence, media, identifiers)
|
@@ -0,0 +1,11 @@
|
|
1
|
+
from typing import Optional
|
2
|
+
|
3
|
+
from .Attribution import Attribution
|
4
|
+
from .URI import URI
|
5
|
+
|
6
|
+
class EvidenceReference:
|
7
|
+
identifier = 'http://gedcomx.org/v1/EvidenceReference'
|
8
|
+
version = 'http://gedcomx.org/conceptual-model/v1'
|
9
|
+
|
10
|
+
def __init__(self, resource: URI, attribution: Optional[Attribution]) -> None:
|
11
|
+
pass
|
gedcomx/Fact.py
ADDED
@@ -0,0 +1,462 @@
|
|
1
|
+
import difflib
|
2
|
+
import re
|
3
|
+
|
4
|
+
from datetime import datetime
|
5
|
+
from enum import Enum
|
6
|
+
from typing import List, Optional
|
7
|
+
|
8
|
+
from .Attribution import Attribution
|
9
|
+
from .Conclusion import ConfidenceLevel
|
10
|
+
from .Date import Date
|
11
|
+
from .Note import Note
|
12
|
+
from .PlaceReference import PlaceReference
|
13
|
+
from .SourceReference import SourceReference
|
14
|
+
from .URI import URI
|
15
|
+
|
16
|
+
from .Conclusion import Conclusion
|
17
|
+
from .Qualifier import Qualifier
|
18
|
+
|
19
|
+
from enum import Enum
|
20
|
+
|
21
|
+
|
22
|
+
class FactType(Enum):
|
23
|
+
# Person Fact Types
|
24
|
+
Adoption = "http://gedcomx.org/Adoption"
|
25
|
+
AdultChristening = "http://gedcomx.org/AdultChristening"
|
26
|
+
Amnesty = "http://gedcomx.org/Amnesty"
|
27
|
+
AncestralHall = "http://gedcomx.org/AncestralHall"
|
28
|
+
AncestralPoem = "http://gedcomx.org/AncestralPoem"
|
29
|
+
Apprenticeship = "http://gedcomx.org/Apprenticeship"
|
30
|
+
Arrest = "http://gedcomx.org/Arrest"
|
31
|
+
Award = "http://gedcomx.org/Award"
|
32
|
+
Baptism = "http://gedcomx.org/Baptism"
|
33
|
+
BarMitzvah = "http://gedcomx.org/BarMitzvah"
|
34
|
+
BatMitzvah = "http://gedcomx.org/BatMitzvah"
|
35
|
+
Birth = "http://gedcomx.org/Birth"
|
36
|
+
BirthNotice = "http://gedcomx.org/BirthNotice"
|
37
|
+
Blessing = "http://gedcomx.org/Blessing"
|
38
|
+
Branch = "http://gedcomx.org/Branch"
|
39
|
+
Burial = "http://gedcomx.org/Burial"
|
40
|
+
Caste = "http://gedcomx.org/Caste"
|
41
|
+
Census = "http://gedcomx.org/Census"
|
42
|
+
Christening = "http://gedcomx.org/Christening"
|
43
|
+
Circumcision = "http://gedcomx.org/Circumcision"
|
44
|
+
Clan = "http://gedcomx.org/Clan"
|
45
|
+
Confirmation = "http://gedcomx.org/Confirmation"
|
46
|
+
Court = "http://gedcomx.org/Court"
|
47
|
+
Cremation = "http://gedcomx.org/Cremation"
|
48
|
+
Death = "http://gedcomx.org/Death"
|
49
|
+
Education = "http://gedcomx.org/Education"
|
50
|
+
EducationEnrollment = "http://gedcomx.org/EducationEnrollment"
|
51
|
+
Emigration = "http://gedcomx.org/Emigration"
|
52
|
+
Enslavement = "http://gedcomx.org/Enslavement"
|
53
|
+
Ethnicity = "http://gedcomx.org/Ethnicity"
|
54
|
+
Excommunication = "http://gedcomx.org/Excommunication"
|
55
|
+
FirstCommunion = "http://gedcomx.org/FirstCommunion"
|
56
|
+
Funeral = "http://gedcomx.org/Funeral"
|
57
|
+
GenderChange = "http://gedcomx.org/GenderChange"
|
58
|
+
GenerationNumber = "http://gedcomx.org/GenerationNumber"
|
59
|
+
Graduation = "http://gedcomx.org/Graduation"
|
60
|
+
Heimat = "http://gedcomx.org/Heimat"
|
61
|
+
Immigration = "http://gedcomx.org/Immigration"
|
62
|
+
Imprisonment = "http://gedcomx.org/Imprisonment"
|
63
|
+
Inquest = "http://gedcomx.org/Inquest"
|
64
|
+
LandTransaction = "http://gedcomx.org/LandTransaction"
|
65
|
+
Language = "http://gedcomx.org/Language"
|
66
|
+
Living = "http://gedcomx.org/Living"
|
67
|
+
MaritalStatus = "http://gedcomx.org/MaritalStatus"
|
68
|
+
Medical = "http://gedcomx.org/Medical"
|
69
|
+
MilitaryAward = "http://gedcomx.org/MilitaryAward"
|
70
|
+
MilitaryDischarge = "http://gedcomx.org/MilitaryDischarge"
|
71
|
+
MilitaryDraftRegistration = "http://gedcomx.org/MilitaryDraftRegistration"
|
72
|
+
MilitaryInduction = "http://gedcomx.org/MilitaryInduction"
|
73
|
+
MilitaryService = "http://gedcomx.org/MilitaryService"
|
74
|
+
Mission = "http://gedcomx.org/Mission"
|
75
|
+
MoveFrom = "http://gedcomx.org/MoveFrom"
|
76
|
+
MoveTo = "http://gedcomx.org/MoveTo"
|
77
|
+
MultipleBirth = "http://gedcomx.org/MultipleBirth"
|
78
|
+
NationalId = "http://gedcomx.org/NationalId"
|
79
|
+
Nationality = "http://gedcomx.org/Nationality"
|
80
|
+
Naturalization = "http://gedcomx.org/Naturalization"
|
81
|
+
NumberOfChildren = "http://gedcomx.org/NumberOfChildren"
|
82
|
+
NumberOfMarriages = "http://gedcomx.org/NumberOfMarriages"
|
83
|
+
Obituary = "http://gedcomx.org/Obituary"
|
84
|
+
OfficialPosition = "http://gedcomx.org/OfficialPosition"
|
85
|
+
Occupation = "http://gedcomx.org/Occupation"
|
86
|
+
Ordination = "http://gedcomx.org/Ordination"
|
87
|
+
Pardon = "http://gedcomx.org/Pardon"
|
88
|
+
PhysicalDescription = "http://gedcomx.org/PhysicalDescription"
|
89
|
+
Probate = "http://gedcomx.org/Probate"
|
90
|
+
Property = "http://gedcomx.org/Property"
|
91
|
+
Race = "http://gedcomx.org/Race"
|
92
|
+
Religion = "http://gedcomx.org/Religion"
|
93
|
+
Residence = "http://gedcomx.org/Residence"
|
94
|
+
Retirement = "http://gedcomx.org/Retirement"
|
95
|
+
Stillbirth = "http://gedcomx.org/Stillbirth"
|
96
|
+
TaxAssessment = "http://gedcomx.org/TaxAssessment"
|
97
|
+
Tribe = "http://gedcomx.org/Tribe"
|
98
|
+
Will = "http://gedcomx.org/Will"
|
99
|
+
Visit = "http://gedcomx.org/Visit"
|
100
|
+
Yahrzeit = "http://gedcomx.org/Yahrzeit"
|
101
|
+
|
102
|
+
# Couple Relationship Fact Types
|
103
|
+
Annulment = "http://gedcomx.org/Annulment"
|
104
|
+
CommonLawMarriage = "http://gedcomx.org/CommonLawMarriage"
|
105
|
+
CivilUnion = "http://gedcomx.org/CivilUnion"
|
106
|
+
Divorce = "http://gedcomx.org/Divorce"
|
107
|
+
DivorceFiling = "http://gedcomx.org/DivorceFiling"
|
108
|
+
DomesticPartnership = "http://gedcomx.org/DomesticPartnership"
|
109
|
+
Engagement = "http://gedcomx.org/Engagement"
|
110
|
+
Marriage = "http://gedcomx.org/Marriage"
|
111
|
+
MarriageBanns = "http://gedcomx.org/MarriageBanns"
|
112
|
+
MarriageContract = "http://gedcomx.org/MarriageContract"
|
113
|
+
MarriageLicense = "http://gedcomx.org/MarriageLicense"
|
114
|
+
MarriageNotice = "http://gedcomx.org/MarriageNotice"
|
115
|
+
Separation = "http://gedcomx.org/Separation"
|
116
|
+
|
117
|
+
# Parent-Child Relationship Fact Types
|
118
|
+
AdoptiveParent = "http://gedcomx.org/AdoptiveParent"
|
119
|
+
BiologicalParent = "http://gedcomx.org/BiologicalParent"
|
120
|
+
ChildOrder = "http://gedcomx.org/ChildOrder"
|
121
|
+
EnteringHeir = "http://gedcomx.org/EnteringHeir"
|
122
|
+
ExitingHeir = "http://gedcomx.org/ExitingHeir"
|
123
|
+
FosterParent = "http://gedcomx.org/FosterParent"
|
124
|
+
GuardianParent = "http://gedcomx.org/GuardianParent"
|
125
|
+
StepParent = "http://gedcomx.org/StepParent"
|
126
|
+
SociologicalParent = "http://gedcomx.org/SociologicalParent"
|
127
|
+
SurrogateParent = "http://gedcomx.org/SurrogateParent"
|
128
|
+
Unknown = 'null'
|
129
|
+
|
130
|
+
@classmethod
|
131
|
+
def from_value(cls, value: str):
|
132
|
+
for member in cls:
|
133
|
+
if member.value == value:
|
134
|
+
return member
|
135
|
+
return FactType.Unknown
|
136
|
+
|
137
|
+
@property
|
138
|
+
def description(self):
|
139
|
+
descriptions = {
|
140
|
+
FactType.Adoption: "A fact of a person's adoption.",
|
141
|
+
FactType.AdultChristening: "A fact of a person's christening or baptism as an adult.",
|
142
|
+
FactType.Amnesty: "A fact of a person's amnesty.",
|
143
|
+
FactType.AncestralHall: "A fact of a person's ancestral hall.",
|
144
|
+
FactType.AncestralPoem: "A fact of a person's ancestral poem.",
|
145
|
+
FactType.Apprenticeship: "A fact of a person's apprenticeship.",
|
146
|
+
FactType.Arrest: "A fact of a person's arrest.",
|
147
|
+
FactType.Award: "A fact of a person's award (medal, honor).",
|
148
|
+
FactType.Baptism: "A fact of a person's baptism.",
|
149
|
+
FactType.BarMitzvah: "A fact of a person's bar mitzvah.",
|
150
|
+
FactType.BatMitzvah: "A fact of a person's bat mitzvah.",
|
151
|
+
FactType.Birth: "A fact of a person's birth.",
|
152
|
+
FactType.BirthNotice: "A fact of a person's birth notice.",
|
153
|
+
FactType.Blessing: "A fact of an official blessing received by a person.",
|
154
|
+
FactType.Branch: "A fact of a person's branch within an extended clan.",
|
155
|
+
FactType.Burial: "A fact of the burial of a person's body after death.",
|
156
|
+
FactType.Caste: "A fact of a person's caste.",
|
157
|
+
FactType.Census: "A fact of a person's participation in a census.",
|
158
|
+
FactType.Christening: "A fact of a person's christening at birth.",
|
159
|
+
FactType.Circumcision: "A fact of a person's circumcision.",
|
160
|
+
FactType.Clan: "A fact of a person's clan.",
|
161
|
+
FactType.Confirmation: "A fact of a person's confirmation.",
|
162
|
+
FactType.Court: "A fact of the appearance of a person in a court proceeding.",
|
163
|
+
FactType.Cremation: "A fact of the cremation of a person's body.",
|
164
|
+
FactType.Death: "A fact of the death of a person.",
|
165
|
+
FactType.Education: "A fact of a person's education or educational achievement.",
|
166
|
+
FactType.EducationEnrollment: "A fact of a person's enrollment in an educational program.",
|
167
|
+
FactType.Emigration: "A fact of the emigration of a person.",
|
168
|
+
FactType.Enslavement: "A fact of the enslavement of a person.",
|
169
|
+
FactType.Ethnicity: "A fact of a person's ethnicity.",
|
170
|
+
FactType.Excommunication: "A fact of a person's excommunication.",
|
171
|
+
FactType.FirstCommunion: "A fact of a person's first communion.",
|
172
|
+
FactType.Funeral: "A fact of a person's funeral.",
|
173
|
+
FactType.GenderChange: "A fact of a person's gender change.",
|
174
|
+
FactType.GenerationNumber: "A fact of a person's generation number.",
|
175
|
+
FactType.Graduation: "A fact of a person's graduation.",
|
176
|
+
FactType.Heimat: "A fact of a person's heimat.",
|
177
|
+
FactType.Immigration: "A fact of a person's immigration.",
|
178
|
+
FactType.Imprisonment: "A fact of a person's imprisonment.",
|
179
|
+
FactType.Inquest: "A legal inquest, often after a suspicious death.",
|
180
|
+
FactType.LandTransaction: "A fact of a land transaction by a person.",
|
181
|
+
FactType.Language: "A fact of a language spoken by a person.",
|
182
|
+
FactType.Living: "A fact of a record of a person's living for a period.",
|
183
|
+
FactType.MaritalStatus: "A fact of a person's marital status.",
|
184
|
+
FactType.Medical: "A fact of a person's medical record.",
|
185
|
+
FactType.MilitaryAward: "A fact of a person's military award.",
|
186
|
+
FactType.MilitaryDischarge: "A fact of a person's military discharge.",
|
187
|
+
FactType.MilitaryDraftRegistration: "A fact of a person's draft registration.",
|
188
|
+
FactType.MilitaryInduction: "A fact of a person's military induction.",
|
189
|
+
FactType.MilitaryService: "A fact of a person's military service.",
|
190
|
+
FactType.Mission: "A fact of a person's church mission.",
|
191
|
+
FactType.MoveFrom: "A fact of a person's move from a location.",
|
192
|
+
FactType.MoveTo: "A fact of a person's move to a new location.",
|
193
|
+
FactType.MultipleBirth: "A fact of a person's birth as part of a multiple birth.",
|
194
|
+
FactType.NationalId: "A fact of a person's national ID.",
|
195
|
+
FactType.Nationality: "A fact of a person's nationality.",
|
196
|
+
FactType.Naturalization: "A fact of a person's naturalization.",
|
197
|
+
FactType.NumberOfChildren: "A fact of the number of children.",
|
198
|
+
FactType.NumberOfMarriages: "A fact of a person's number of marriages.",
|
199
|
+
FactType.Obituary: "A fact of a person's obituary.",
|
200
|
+
FactType.OfficialPosition: "A fact of a person's official government position.",
|
201
|
+
FactType.Occupation: "A fact of a person's occupation.",
|
202
|
+
FactType.Ordination: "A fact of a person's ordination.",
|
203
|
+
FactType.Pardon: "A fact of a person's legal pardon.",
|
204
|
+
FactType.PhysicalDescription: "A fact of a person's physical description.",
|
205
|
+
FactType.Probate: "A fact of a person's probate receipt.",
|
206
|
+
FactType.Property: "A fact of a person's property.",
|
207
|
+
FactType.Race: "A fact of a person's race.",
|
208
|
+
FactType.Religion: "A fact of a person's religion.",
|
209
|
+
FactType.Residence: "A fact of a person's residence.",
|
210
|
+
FactType.Retirement: "A fact of a person's retirement.",
|
211
|
+
FactType.Stillbirth: "A fact of a person's stillbirth.",
|
212
|
+
FactType.TaxAssessment: "A fact of a person's tax assessment.",
|
213
|
+
FactType.Tribe: "A fact of a person's tribe.",
|
214
|
+
FactType.Will: "A fact of a person's will.",
|
215
|
+
FactType.Visit: "A fact of a person's visit to a place.",
|
216
|
+
FactType.Yahrzeit: "A fact of a person's yahrzeit.",
|
217
|
+
FactType.AdoptiveParent: "A fact about an adoptive relationship.",
|
218
|
+
FactType.BiologicalParent: "A fact about the biological relationship.",
|
219
|
+
FactType.ChildOrder: "A fact about the child order.",
|
220
|
+
FactType.EnteringHeir: "A fact about an entering heir relationship.",
|
221
|
+
FactType.ExitingHeir: "A fact about an exiting heir relationship.",
|
222
|
+
FactType.FosterParent: "A fact about a foster relationship.",
|
223
|
+
FactType.GuardianParent: "A fact about legal guardianship.",
|
224
|
+
FactType.StepParent: "A fact about the step relationship.",
|
225
|
+
FactType.SociologicalParent: "A fact about a sociological relationship.",
|
226
|
+
FactType.SurrogateParent: "A fact about a surrogate relationship.",
|
227
|
+
FactType.Annulment: "A fact of an annulment of marriage.",
|
228
|
+
FactType.CommonLawMarriage: "A fact of marriage by common law.",
|
229
|
+
FactType.CivilUnion: "A fact of a civil union.",
|
230
|
+
FactType.DomesticPartnership: "A fact of a domestic partnership.",
|
231
|
+
FactType.Engagement: "A fact of an engagement to marry.",
|
232
|
+
FactType.MarriageBanns: "A fact of marriage banns.",
|
233
|
+
FactType.MarriageContract: "A fact of a marriage contract.",
|
234
|
+
FactType.MarriageLicense: "A fact of a marriage license.",
|
235
|
+
FactType.MarriageNotice: "A fact of a marriage notice.",
|
236
|
+
FactType.Separation: "A fact of a couple's separation."
|
237
|
+
}
|
238
|
+
return descriptions.get(self, "No description available.")
|
239
|
+
|
240
|
+
@staticmethod
|
241
|
+
def guess(description):
|
242
|
+
keywords_to_fact_type = {
|
243
|
+
# Person Fact Types
|
244
|
+
"adoption": FactType.Adoption,
|
245
|
+
"adult christening": FactType.AdultChristening,
|
246
|
+
"amnesty": FactType.Amnesty,
|
247
|
+
"ancestral hall": FactType.AncestralHall,
|
248
|
+
"ancestral poem": FactType.AncestralPoem,
|
249
|
+
"apprenticeship": FactType.Apprenticeship,
|
250
|
+
"arrest": FactType.Arrest,
|
251
|
+
"award": FactType.Award,
|
252
|
+
"baptism": FactType.Baptism,
|
253
|
+
"bar mitzvah": FactType.BarMitzvah,
|
254
|
+
"bat mitzvah": FactType.BatMitzvah,
|
255
|
+
"birth": FactType.Birth,
|
256
|
+
"birth notice": FactType.BirthNotice,
|
257
|
+
"blessing": FactType.Blessing,
|
258
|
+
"branch": FactType.Branch,
|
259
|
+
"burial": FactType.Burial,
|
260
|
+
"caste": FactType.Caste,
|
261
|
+
"census": FactType.Census,
|
262
|
+
"christening": FactType.Christening,
|
263
|
+
"circumcision": FactType.Circumcision,
|
264
|
+
"clan": FactType.Clan,
|
265
|
+
"confirmation": FactType.Confirmation,
|
266
|
+
"court": FactType.Court,
|
267
|
+
"cremation": FactType.Cremation,
|
268
|
+
"death": FactType.Death,
|
269
|
+
"education": FactType.Education,
|
270
|
+
"education enrollment": FactType.EducationEnrollment,
|
271
|
+
"emigration": FactType.Emigration,
|
272
|
+
"enslavement": FactType.Enslavement,
|
273
|
+
"ethnicity": FactType.Ethnicity,
|
274
|
+
"excommunication": FactType.Excommunication,
|
275
|
+
"first communion": FactType.FirstCommunion,
|
276
|
+
"funeral": FactType.Funeral,
|
277
|
+
"gender change": FactType.GenderChange,
|
278
|
+
"generation number": FactType.GenerationNumber,
|
279
|
+
"graduation": FactType.Graduation,
|
280
|
+
"heimat": FactType.Heimat,
|
281
|
+
"immigration": FactType.Immigration,
|
282
|
+
"imprisonment": FactType.Imprisonment,
|
283
|
+
"inquest": FactType.Inquest,
|
284
|
+
"land transaction": FactType.LandTransaction,
|
285
|
+
"language": FactType.Language,
|
286
|
+
"living": FactType.Living,
|
287
|
+
"marital status": FactType.MaritalStatus,
|
288
|
+
"medical": FactType.Medical,
|
289
|
+
"military award": FactType.MilitaryAward,
|
290
|
+
"military discharge": FactType.MilitaryDischarge,
|
291
|
+
"military draft registration": FactType.MilitaryDraftRegistration,
|
292
|
+
"military induction": FactType.MilitaryInduction,
|
293
|
+
"military service": FactType.MilitaryService,
|
294
|
+
"mission": FactType.Mission,
|
295
|
+
"move from": FactType.MoveFrom,
|
296
|
+
"move to": FactType.MoveTo,
|
297
|
+
"multiple birth": FactType.MultipleBirth,
|
298
|
+
"national id": FactType.NationalId,
|
299
|
+
"nationality": FactType.Nationality,
|
300
|
+
"naturalization": FactType.Naturalization,
|
301
|
+
"number of children": FactType.NumberOfChildren,
|
302
|
+
"number of marriages": FactType.NumberOfMarriages,
|
303
|
+
"obituary": FactType.Obituary,
|
304
|
+
"official position": FactType.OfficialPosition,
|
305
|
+
"occupation": FactType.Occupation,
|
306
|
+
"ordination": FactType.Ordination,
|
307
|
+
"pardon": FactType.Pardon,
|
308
|
+
"physical description": FactType.PhysicalDescription,
|
309
|
+
"probate": FactType.Probate,
|
310
|
+
"property": FactType.Property,
|
311
|
+
"race": FactType.Race,
|
312
|
+
"religion": FactType.Religion,
|
313
|
+
"residence": FactType.Residence,
|
314
|
+
"retirement": FactType.Retirement,
|
315
|
+
"stillbirth": FactType.Stillbirth,
|
316
|
+
"tax assessment": FactType.TaxAssessment,
|
317
|
+
"tribe": FactType.Tribe,
|
318
|
+
"will": FactType.Will,
|
319
|
+
"visit": FactType.Visit,
|
320
|
+
"yahrzeit": FactType.Yahrzeit,
|
321
|
+
|
322
|
+
# Couple Relationship Fact Types
|
323
|
+
"annulment": FactType.Annulment,
|
324
|
+
"common law marriage": FactType.CommonLawMarriage,
|
325
|
+
"civil union": FactType.CivilUnion,
|
326
|
+
"divorce": FactType.Divorce,
|
327
|
+
"divorce filing": FactType.DivorceFiling,
|
328
|
+
"domestic partnership": FactType.DomesticPartnership,
|
329
|
+
"engagement": FactType.Engagement,
|
330
|
+
"marriage": FactType.Marriage,
|
331
|
+
"marriage banns": FactType.MarriageBanns,
|
332
|
+
"marriage contract": FactType.MarriageContract,
|
333
|
+
"marriage license": FactType.MarriageLicense,
|
334
|
+
"marriage notice": FactType.MarriageNotice,
|
335
|
+
"couple number of children": FactType.NumberOfChildren,
|
336
|
+
"separation": FactType.Separation,
|
337
|
+
|
338
|
+
# Parent-Child Relationship Fact Types
|
339
|
+
"adoptive parent": FactType.AdoptiveParent,
|
340
|
+
"biological parent": FactType.BiologicalParent,
|
341
|
+
"child order": FactType.ChildOrder,
|
342
|
+
"entering heir": FactType.EnteringHeir,
|
343
|
+
"exiting heir": FactType.ExitingHeir,
|
344
|
+
"foster parent": FactType.FosterParent,
|
345
|
+
"guardian parent": FactType.GuardianParent,
|
346
|
+
"step parent": FactType.StepParent,
|
347
|
+
"sociological parent": FactType.SociologicalParent,
|
348
|
+
"surrogate parent": FactType.SurrogateParent
|
349
|
+
}
|
350
|
+
|
351
|
+
|
352
|
+
description_lower = description.lower()
|
353
|
+
|
354
|
+
# Replace any non-alphanumeric characters with a space
|
355
|
+
description_clean = re.sub(r'[^a-z0-9\s]', ' ', description_lower)
|
356
|
+
|
357
|
+
# Get a list of words in the cleaned description
|
358
|
+
words = description_clean.split()
|
359
|
+
|
360
|
+
# Check for the best matching keyword in the description
|
361
|
+
for word in words:
|
362
|
+
matches = difflib.get_close_matches(word, keywords_to_fact_type.keys(), n=1, cutoff=0.8)
|
363
|
+
if matches:
|
364
|
+
print(f"Guessed '{description} to be of fact type: {keywords_to_fact_type[matches[0]]}")
|
365
|
+
return keywords_to_fact_type[matches[0]]
|
366
|
+
return None
|
367
|
+
|
368
|
+
|
369
|
+
class FactQualifier(Enum):
|
370
|
+
Age = "http://gedcomx.org/Age"
|
371
|
+
Cause = "http://gedcomx.org/Cause"
|
372
|
+
Religion = "http://gedcomx.org/Religion"
|
373
|
+
Transport = "http://gedcomx.org/Transport"
|
374
|
+
NonConsensual = "http://gedcomx.org/NonConsensual"
|
375
|
+
|
376
|
+
@property
|
377
|
+
def description(self):
|
378
|
+
descriptions = {
|
379
|
+
FactQualifier.Age: "The age of a person at the event described by the fact.",
|
380
|
+
FactQualifier.Cause: "The cause of the fact, such as the cause of death.",
|
381
|
+
FactQualifier.Religion: "The religion associated with a religious event such as a baptism or excommunication.",
|
382
|
+
FactQualifier.Transport: "The name of the transport associated with an event that indicates a move.",
|
383
|
+
FactQualifier.NonConsensual: "An indicator that the event occurred non-consensually, e.g., under enslavement."
|
384
|
+
}
|
385
|
+
return descriptions.get(self, "No description available.")
|
386
|
+
|
387
|
+
|
388
|
+
class Fact(Conclusion):
|
389
|
+
identifier = 'http://gedcomx.org/v1/Fact'
|
390
|
+
version = 'http://gedcomx.org/conceptual-model/v1'
|
391
|
+
|
392
|
+
def __init__(self,
|
393
|
+
id: str = None,
|
394
|
+
lang: str = 'en',
|
395
|
+
sources: Optional[List[SourceReference]] = [],
|
396
|
+
analysis: URI = None,
|
397
|
+
notes: Optional[List[Note]] = [],
|
398
|
+
confidence: ConfidenceLevel = None,
|
399
|
+
attribution: Attribution = None,
|
400
|
+
type: FactType = None,
|
401
|
+
date: Optional[Date] = None,
|
402
|
+
place: Optional[PlaceReference] = None,
|
403
|
+
value: Optional[str] = None,
|
404
|
+
qualifiers = []) -> None: #qualifiers: Optional[List[FactQualifier]] = []) -> None:
|
405
|
+
super().__init__(id, lang, sources, analysis, notes, confidence, attribution)
|
406
|
+
self.type = type
|
407
|
+
self.date = date
|
408
|
+
self.place = place
|
409
|
+
self.value = value
|
410
|
+
self.qualifiers = qualifiers
|
411
|
+
|
412
|
+
@property
|
413
|
+
def _as_dict_(self):
|
414
|
+
def _serialize(value):
|
415
|
+
if isinstance(value, (str, int, float, bool, type(None))):
|
416
|
+
return value
|
417
|
+
elif isinstance(value, dict):
|
418
|
+
return {k: _serialize(v) for k, v in value.items()}
|
419
|
+
elif isinstance(value, (list, tuple, set)):
|
420
|
+
return [_serialize(v) for v in value]
|
421
|
+
elif hasattr(value, "_as_dict_"):
|
422
|
+
return value._as_dict_
|
423
|
+
else:
|
424
|
+
return str("UKN " + value) # fallback for unknown objects
|
425
|
+
|
426
|
+
# Only add Relationship-specific fields
|
427
|
+
fact_fields = {
|
428
|
+
'type': self.type.value if self.type else None,
|
429
|
+
'date': self.date._prop_dict() if self.date else None,
|
430
|
+
'place': self.place._as_dict_ if self.place else None,
|
431
|
+
'value': self.value,
|
432
|
+
'qualifiers': [q.value for q in self.qualifiers] if self.qualifiers else []
|
433
|
+
}
|
434
|
+
|
435
|
+
# Serialize and exclude None values
|
436
|
+
for key, value in fact_fields.items():
|
437
|
+
if value is not None:
|
438
|
+
fact_fields[key] = _serialize(value)
|
439
|
+
|
440
|
+
|
441
|
+
return fact_fields
|
442
|
+
|
443
|
+
def ensure_list(val):
|
444
|
+
if val is None:
|
445
|
+
return []
|
446
|
+
return val if isinstance(val, list) else [val]
|
447
|
+
# Fact
|
448
|
+
Fact._from_json_ = classmethod(lambda cls, data: cls(
|
449
|
+
id=data.get('id'),
|
450
|
+
lang=data.get('lang', 'en'),
|
451
|
+
sources=[SourceReference._from_json_(s) for s in ensure_list(data.get('sources'))],
|
452
|
+
analysis=URI._from_json_(data['analysis']) if data.get('analysis') else None,
|
453
|
+
notes=[Note._from_json_(n) for n in ensure_list(data.get('notes'))],
|
454
|
+
confidence=ConfidenceLevel._from_json_(data['confidence']) if data.get('confidence') else None,
|
455
|
+
attribution=Attribution._from_json_(data['attribution']) if data.get('attribution') else None,
|
456
|
+
type=FactType.from_value(data['type']) if data.get('type') else None,
|
457
|
+
date=Date._from_json_(data['date']) if data.get('date') else None,
|
458
|
+
place=PlaceReference._from_json_(data['place']) if data.get('place') else None,
|
459
|
+
value=data.get('value'),
|
460
|
+
qualifiers=[Qualifier._from_json_(q) for q in ensure_list(data.get('qualifiers'))]
|
461
|
+
))
|
462
|
+
|