Debian Codegraph @

reports/igi-filter.ll

raw
1 /*
2 * @progname igi-filter.ll
3 * @version 1 of 1993-02-15
4 * @author Jim Eggert ([email protected])
5 * @category
6 * @output GedCom
7 * @description
8 *
9 * Write GedCom of families/events containing given TAG/VALUE
10 *
11 This program is meant to help you filter out useful data from a big IGI
12 download. You specify what GEDCOM tag you want to look at, and what value
13 you want to accept. Then it writes a GEDCOM file that contains only those
14 IGI entries that have what you want. So for example, suppose you have
15 downloaded all the Hammer families from the IGI, but are really interested
16 only in those from Harthausen. In this case, you specify PLAC as the GEDCOM
17 tag, and Harthausen as the value, and you get a GEDCOM file with only the
18 Harthausen Hammer families.
19
20 The program will look at every GEDCOM level to find the sought tag, in
21 both individual and family records. For NAME and PLAC entries, all
22 name or components are searched for a match. A match is defined as
23 string equality for all provided or available characters, ignoring
24 case. Thus entering Harth as a desired value will match Harthausen,
25 Harthofen, and Hart as well. Once a matching value is found, the
26 program will include in its output the whole matching "family" from
27 the IGI data. (An IGI "family" is really just an event.)
28
29 This program will run on non-IGI data also. For non-IGI data, it will
30 generally include somewhat more people in its output file that you
31 might expect. No big deal.
32
33 igi-filter - a LifeLines program to filter IGI data
34 by Jim Eggert ([email protected])
35 Version 1, 15 February 1993
36
37 */
38
39 global(this_one)
40 global(the_tag)
41 global(the_value)
42 global(the_length)
43 global(name_tag)
44 global(plac_tag)
45
46 proc check_value(a_string) {
47 set(a_length,strlen(a_string))
48 if (gt(a_length,the_length)) {
49 if (not(strcmp(upper(trim(a_string,the_length)),the_value))) {
50 set(this_one,1)
51 }
52 } else {
53 if (not(strcmp(trim(the_value,a_length),upper(a_string)))) {
54 set(this_one,1)
55 }
56 }
57 }
58
59 proc check_values(root) {
60 list(nlist)
61 traverse(root,node,level) {
62 if (and(not(this_one),not(strcmp(tag(node),the_tag)))) {
63 if (name_tag) {
64 extractnames(node,nlist,n,ns)
65 forlist(nlist,n0,nnum) {
66 call check_value(n0)
67 }
68 }
69 elsif (plac_tag) {
70 extractplaces(node,nlist,n)
71 forlist(nlist,n0,nnum) {
72 call check_value(n0)
73 }
74 }
75 else {
76 call check_value(value(node))
77 }
78 }
79 }
80 }
81
82
83 proc main() {
84 indiset(accept)
85 getstrmsg(the_tag,"Enter tag for filtering:")
86 set(the_tag,save(upper(the_tag)))
87 if (not(strcmp(the_tag,"NAME"))) { set(name_tag,1) }
88 else { set(name_tag,0) }
89 if (not(strcmp(the_tag,"PLAC"))) { set(plac_tag,1) }
90 else { set(plac_tag,0) }
91 getstrmsg(the_value,"Enter value to be accepted:")
92 set(the_value,save(upper(the_value)))
93 set(the_length,strlen(the_value))
94
95 set(accepted,0)
96 forindi(person,pnum) {
97 set(this_one,0)
98 call check_values(inode(person))
99 if (this_one) {
100 addtoset(accept,person,0)
101 set(accepted,add(accepted,1))
102 }
103 }
104 print("Passed ") print(d(accepted))
105 print(" of ") print(d(pnum)) print(" individuals.\n")
106 set(accepted,0)
107 forfam(family,fnum) {
108 set(this_one,0)
109 call check_values(fnode(family))
110 if (this_one) {
111 set(accepted,add(accepted,1))
112 if (person,husband(family)) {
113 addtoset(accept,person,1)
114 }
115 elsif (person,wife(family)) {
116 addtoset(accept,person,1)
117 }
118 else {
119 children(family,person,pnum) {
120 if (eq(pnum,1)) { addtoset(accept,person,2) }
121 }
122 }
123 }
124 }
125 print("Passed ") print(d(accepted))
126 print(" of ") print(d(fnum)) print(" families.\nWriting GEDCOM file...")
127 set(accept,union(accept,spouseset(accept)))
128 set(accept,union(accept,parentset(accept)))
129 set(accept,union(accept,childset(accept)))
130 gengedcom(accept)
131 "0 TRLR\n"
132 print("done")
133 }
134