Debian Codegraph @

reports/db_summary.ll

raw
1 /*
2 * @progname db_summary.ll
3 * @version 1
4 * @author Eggert
5 * @category
6 * @output Text
7 * @description
8
9 This program gives you summary statistics on your database. It
10 calculates the number of birth, baptism, marriage, death, and burial
11 events, and gives the distribution over centuries of birth/baptisms,
12 death/burials, and marriages. It tells you how many different names
13 (given names and surnames separately) there are in the database, and
14 how many persons have no surname in the database.
15
16 db_summary - a LifeLines database summary program
17 by Jim Eggert ([email protected])
18 Version 1, 29 March 1995 Initial release
19 */
20
21 proc main() {
22 table(surnames)
23 table(givens)
24 list(bcents)
25 list(dcents)
26 list(mcents)
27
28 list(namelist)
29
30 set(nsurnames,0)
31 set(ngivens,0)
32 set(nnosurnames,0)
33 set(nnogivens,0)
34 set(nemptysurnames,0)
35 set(nbirths,0)
36 set(nbaptisms,0)
37 set(nmarrs,0)
38 set(ndeaths,0)
39 set(nburials,0)
40
41 print("Collecting individual statistics...")
42 forindi(person,pnum) {
43 /* Do individual event statistics */
44 set(by,0)
45 if (b,birth(person)) {
46 incr(nbirths)
47 extractdate(b,bd,bm,by)
48 }
49 if (b,baptism(person)) {
50 incr(nbaptisms)
51 if (not(by)) { extractdate(b,bd,bm,by) }
52 }
53 call increment_century(bcents,by)
54
55 set(dy,0)
56 if (d,death(person)) {
57 incr(ndeaths)
58 extractdate(d,dd,dm,dy)
59 }
60 if (d,burial(person)) {
61 incr(nburials)
62 if (not(dy)) { extractdate(d,dd,dm,dy) }
63 }
64 call increment_century(dcents,dy)
65
66 /* Do name statistics */
67 extractnames(inode(person),namelist,nnames,isurname)
68 if (not(isurname)) { incr(nnosurnames) }
69 forlist(namelist,name,nnum) {
70 if (eq(nnum,isurname)) {
71 if (not(lookup(surnames,name))) {
72 incr(nsurnames)
73 insert(surnames,save(name),save(key(person)))
74 }
75 if (not(strcmp(name,""))) {
76 incr(nemptysurnames)
77 }
78 if (not(name)) { incr(nnosurnames) }
79 }
80 else {
81 if (not(lookup(givens,name))) {
82 incr(ngivens)
83 insert(givens,save(name),save(key(person)))
84 }
85 }
86 }
87 }
88
89 print("done.\nCollecting family statistics...")
90 forfam(family,fnum) {
91 set(by,0)
92 if (m,marriage(family)) {
93 incr(nmarrs)
94 extractdate(m,md,mm,my)
95 call increment_century(mcents,my)
96 }
97 }
98
99 print("done.\nGenerating report...")
100 "The database " database() " contains:\n"
101 d(pnum) " individuals\n"
102 d(nsurnames) " unique surnames\n"
103 d(ngivens) " unique given names\n"
104 d(nemptysurnames) " individuals with empty surnames\n"
105 d(nnosurnames) " individuals with no surname\n"
106 d(nbirths) " birth events\n"
107 d(nbaptisms) " baptism events\n"
108 "Birth/baptism events distributed by century as\n"
109 call list_centuries(bcents)
110 d(ndeaths) " death events\n"
111 d(nburials) " burial events\n"
112 "Death/burial events distributed by century as\n"
113 call list_centuries(dcents)
114 "\n"
115 d(fnum) " families\n"
116 d(nmarrs) " marriage events distributed by century as\n"
117 call list_centuries(mcents)
118 print("done.\n")
119 }
120
121 proc increment_century(centuries,year) {
122 if (year) {
123 set(century,div(year,100))
124 if (not(length(centuries))) {
125 enqueue(centuries,century)
126 enqueue(centuries,1)
127 }
128 else {
129 set(first_century,dequeue(centuries))
130 while (lt(century,first_century)) {
131 requeue(centuries,0)
132 set(first_century,sub(first_century,1))
133 }
134 set(index,add(1,sub(century,first_century)))
135 setel(centuries,index,add(getel(centuries,index),1))
136 requeue(centuries,first_century)
137 }
138 }
139 }
140
141 proc list_centuries(centuries) {
142 set(century,dequeue(centuries))
143 while (count,dequeue(centuries)) {
144 " " d(century) "00s " d(count) "\n"
145 incr(century)
146 }
147 }