File: est_life_span.ll

package info (click to toggle)
lifelines 3.0.50-2
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 11,140 kB
  • ctags: 6,517
  • sloc: ansic: 57,468; xml: 8,014; sh: 4,255; makefile: 848; yacc: 601; perl: 170; sed: 16
file content (211 lines) | stat: -rw-r--r-- 8,474 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
/*
 * @progname       est_life_span.ll
 * @version        none
 * @author         Rafal Prinke
 * @category       
 * @output         Text
 * @description

The program below finds the widest possible span of life, estimating
the uncertain and some unknown dates on the basis of user defined
values in the table for various combinations of date modifiers etc.
Then it compares the midpoints of this with midpoints of others'
life spans and if they fall within a user defined range, the two
are considered "possibly identical". This is actually just one procedure
of several that should be in a program like that - but perhaps the
most important one as people may change names, occupations, etc.
but they cannot change the time period. I added two arbitrary tags:
FAPP and LAPP for "first/last appearance" in sources.

At present the program compares only the life midpoints and surnames
(exactly as they are recorded). Adding other elements for comparison
should not be a problem - but there should be a more complicated
procedure for comparing names. I do not like soundex as it is misleading
(and my bias is founded on the fact that two spellings of my own
surname - Prinke and Brinke - never match under the standard soundex :-)
Perhaps a soundex that would INCLUDE conversion of the first character
into number would nee to be considered? That does not solve many problems
of non-English name, either. So perhaps a user defined soundex? This
might be possible with user defined functions!

The procedure below does not deal with BETWEEN dates for death yet.
Also people who have no dates at all are not dealt with properly -
they should be compared with everyone (generating a lot of rubbish
output) or their life span should be found out from children or spouses.
 */

global(year1)  /* earliest possible */
global(year2)  /* latest possible */
global(diffs)
global(someone)
global(another)

proc life_span(someone)
{
        set(year1,0)
        if (bt,birth(someone)) {
                set(year1,atoi(year(bt)))
                if (ne(index(upper(date(bt)),"BEF",1),0)) {
                        set(year1,sub(year1,lookup(diffs,"bef_birt")))
                }
                if (and(ne(index(upper(date(bt)),"ABT",1),0),ne(index(upper(date(bt)),"EST",1),0)))
		{
                        set(year1,sub(year1,lookup(diffs,"abt_birt")))
                }
        }
        if (eq(year1,0)) {
                if (bp,baptism(someone)) {
                        set(year1,atoi(year(bp)))
                        if (ne(index(upper(date(bp)),"BEF",1),0)) {
                                set(year1,sub(year1,lookup(diffs,"bef_birt")))
                        }
                        if (and(ne(index(upper(date(bp)),"ABT",1),0),ne(index(upper(date(bp)),"EST",1),0)))
			{
                                set(year1,sub(year1,lookup(diffs,"abt_birt")))
                        }
                }
        }
        if (eq(year1,0)) {
                set(r, inode(someone))
                fornodes (r, n) {
                        if (eq(0, strcmp("FAPP", tag(n)))) {
                                extractdate(n,da,mo,ye)
                                set(year1,ye)
                                set(year1,sub(year1,lookup(diffs,"app1")))
                        }
                }
        }
        if (and(eq(year1,0),ne(nfamilies(someone),0))) {
                set(myear,2000)
                families(someone,fm,sp,mnr) {
                        set(fyear,atoi(year(marriage(fm))))
                        if (lt(fyear,myear)) {
                                set (myear,fyear)
                                set(mar,marriage(fm))
                        }
                }
                if (and(ne(myear,2000),ne(myear,0))) {
                        set(year1,sub(myear,lookup(diffs,"f_marr")))
                        if (ne(index(upper(date(mar)),"BEF",1),0)) {
                                set(year1,sub(year1,lookup(diffs,"bef_marr")))
                        }
                        if (and(ne(index(upper(date(mar)),"ABT",1),0),ne(index(upper(date(bp)),"EST",1),0)))
			{
                                set(year1,sub(year1,lookup(diffs,"abt_marr")))
                        }
                }
        }

        set(year2,0)
        if (dt,death(someone)) {
                set(year2,atoi(year(dt)))
                if (ne(index(upper(date(dt)),"AFT",1),0)) {
                        set(year2,add(year2,lookup(diffs,"aft_deat")))
                }
                if (and(ne(index(upper(date(dt)),"ABT",1),0),ne(index(upper(date(dt)),"EST",1),0)))
		{
                        set(year2,add(year2,lookup(diffs,"abt_deat")))
                }
        }
        if (eq(year2,0)) {
                if (br,burial(someone)) {
                        set(year2,atoi(year(br)))
                        if (ne(index(upper(date(br)),"AFT",1),0)) {
                                set(year2,add(year2,lookup(diffs,"aft_deat")))
                        }
                        if (and(ne(index(upper(date(br)),"ABT",1),0),ne(index(upper(date(br)),"EST",1),0)))
			{
                                set(year2,add(year2,lookup(diffs,"abt_deat")))
                        }
                }
        }
        if (eq(year2,0)) {
                set(r, inode(someone))
                fornodes (r, n) {
                        if (eq(0, strcmp("LAPP", tag(n)))) {
                                extractdate(n,da,mo,ye)
                                set(year2,ye)
                                set(year2,add(year2,lookup(diffs,"app2")))
                        }
                }
        }
        if (and(eq(year2,0),ne(nfamilies(someone),0))) {
                set(myear,0)
                families(someone,fm,sp,mnr) {
                        set(lyear,atoi(year(marriage(fm))))
                        if (gt(lyear,myear)) {
                                set (myear,lyear)
                                set(mar,marriage(fm))
                        }
                }
                if (ne(myear,0)) {
                        set(year2,add(myear,lookup(diffs,"l_marr")))
                        if (ne(index(upper(date(mar)),"AFT",1),0)) {
                                set(year2,add(year2,lookup(diffs,"aft_marr")))
                        }
                        if (and(ne(index(upper(date(mar)),"ABT",1),0),ne(index(upper(date(mar)),"EST",1),0)))
			{
                                set(year2,add(year2,lookup(diffs,"abt_marr")))
                        }
                }
        }
        if (ne(add(year1,year2),0)) {
        if (and(eq(year1,0),ne(year2,0))) {
                set(year1,sub(year2,lookup(diffs,"birt_deat")))
        }
        if (and(eq(year2,0),ne(year1,0))) {
                set(year2,add(year1,lookup(diffs,"birt_deat")))
        }
        }
}

proc main()
{
        table(diffs)   /* values for range of date modifiers etc. */
        insert(diffs,"bef_birt", 10)
        insert(diffs,"abt_birt", 10)
        insert(diffs,"aft_deat", 10)
        insert(diffs,"abt_deat", 10)
        insert(diffs,"f_marr",25)
        insert(diffs,"l_marr",13)
        insert(diffs,"bef_marr", 10)
        insert(diffs,"abt_marr", 8)
        insert(diffs,"aft_marr", 2)
        insert(diffs,"app1", 10)
        insert(diffs,"app2", 10)
        insert(diffs,"birt_deat", 88)
        insert(diffs,"dist", 50)

        forindi(someone,n1) {
                call life_span(someone)
                set(pb1,surname(someone))
                set(pb1,save(pb1))
          set(midspan1,div(add(year1,year2),2))
                forindi(another,n2) {
                print(d(n1)," ",d(n2),"\n")
                    if (gt(n2,n1)) {
                        call life_span(another)
                        set(pb2,surname(another))
                        set(pb2,save(pb2))
                        set(midspan2,div(add(year1,year2),2))
                        set(cont,0)
if (ge(midspan1,midspan2)) {
        if (lt(sub(midspan1,midspan2),lookup(diffs,"dist"))) {
                set(cont,1)
        }
}
if (ge(midspan2,midspan1)) {
        if (lt(sub(midspan2,midspan1),lookup(diffs,"dist"))) {
                set(cont,1)
        }
}
 if (and(eq(cont,1),eq(strcmp(pb1,pb2),0))) {
                " possibly contemporary: " nl()
          key(someone) " " name(someone) " " d(midspan1) " " pb1 nl()
                key(another) " " name(another) " " d(midspan2) " " pb2 nl()

 }
                    }
                }
        }
}