Skip to content

Commit 329d425

Browse files
committed
handle identifiers
1 parent 816f056 commit 329d425

5 files changed

Lines changed: 127 additions & 5 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ The above will overwrite the files in `edu/virginia/ged5to7/config/` with update
5757
- `_DATE``DATE`
5858
- `ASSO`.`RELA``ASSO`.`ROLE`
5959
- other?
60-
- [ ] change `RFN`, `RIN`, and `AFN` to `EXID`
61-
- [ ] change `_FSFTID`, `_APID` to `EXID`
60+
- [x] Enumerated values
61+
- [x] Normalize case
62+
- [x] Convert user-text to `PHRASE`s
63+
- [x] change `RFN`, `RIN`, and `AFN` to `EXID`
64+
- [x] change `_FSFTID`, `_APID` to `EXID`
6265
- [ ] Convert `MEDI`.`FORM` payloads to media types
63-
- [ ] Enumerated values
64-
- [ ] Normalize case
65-
- [ ] Convert user-text to `PHRASE`s
6666
- [ ] Convert `FONE` and `ROMN` to `TRAN` and their `TYPE`s to BCP-47 `LANG`s
6767
- [ ] remove `SUBN`, `HEAD`.`FILE`, `HEAD`.`CHAR`
6868
- (deferred) `HEAD`.`PLAC` was originally on this list, but has been deferred to a later version

edu/virginia/ged5to7/Converter5to7.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public Converter5to7(String filename, int id_base) {
6060
new ObjectFilter(),
6161
new LanguageFilter(),
6262
new EnumFilter(),
63+
new ExidFilter(),
6364
};
6465
for(Filter f : filters) {
6566
java.util.LinkedList<GedStruct> created = new java.util.LinkedList<GedStruct>();
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package edu.virginia.ged5to7.pipeline;
2+
import edu.virginia.ged5to7.GedStruct;
3+
import edu.virginia.ged5to7.GedcomDefinitions;
4+
5+
public class EnumFilter implements Filter {
6+
public java.util.Collection<GedStruct> update(GedStruct s) {
7+
GedcomDefinitions def = GedcomDefinitions.getDefinitions();
8+
String pu = def.payloadURI(s.uri);
9+
if ("https://gedcom.io/terms/v7/type-Enum".equals(pu)) {
10+
String bit = s.payload.trim().toUpperCase().replaceAll("[- ]+","_");
11+
String uri = def.enumURI(s.uri, bit);
12+
if (uri == null) {
13+
new GedStruct(s, "https://gedcom.io/terms/v7/PHRASE", s.payload);
14+
s.payload = def.enumURI(s.uri, "OTHER") == null ? "_OTHER" : "OTHER";
15+
} else {
16+
s.payload = bit;
17+
}
18+
} else if ("https://gedcom.io/terms/v7/type-List#Enum".equals(pu)) {
19+
String[] bits = s.payload.split(",");
20+
boolean other = false;
21+
String others = s.payload;
22+
s.payload = "";
23+
for(String bit : bits) {
24+
bit = bit.trim().toUpperCase();
25+
if (def.enumURI(s.uri, bit) != null) {
26+
if (s.payload.length() > 0) s.payload += ", ";
27+
s.payload += bit;
28+
} else {
29+
other = true;
30+
}
31+
}
32+
if (other) {
33+
if (s.payload.length() > 0) s.payload += ", ";
34+
s.payload = def.enumURI(s.uri, "OTHER") == null ? "_OTHER" : "OTHER";
35+
new GedStruct(s, "https://gedcom.io/terms/v7/PHRASE", others);
36+
}
37+
}
38+
39+
for(GedStruct s2 : s.sub) update(s2);
40+
return null;
41+
}
42+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package edu.virginia.ged5to7.pipeline;
2+
import edu.virginia.ged5to7.GedStruct;
3+
import edu.virginia.ged5to7.GedcomDefinitions;
4+
5+
public class ExidFilter implements Filter {
6+
public java.util.Collection<GedStruct> update(GedStruct s) {
7+
boolean changed = true;
8+
switch(s.tag) {
9+
case "AFN":
10+
s.uri = "https://gedcom.io/terms/v7/EXID";
11+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "https://www.familysearch.org/wiki/en/Ancestral_File");
12+
break;
13+
case "RFN":
14+
s.uri = "https://gedcom.io/terms/v7/EXID";
15+
int colon = s.payload.indexOf(':');
16+
if (colon < 0) {
17+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "https://gedcom.io/terms/v7/RFN");
18+
} else {
19+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "https://gedcom.io/terms/v7/RFN#"+s.payload.substring(0,colon));
20+
s.payload = s.payload.substring(colon+1);
21+
}
22+
break;
23+
case "RIN":
24+
s.uri = "https://gedcom.io/terms/v7/REFN";
25+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "RIN");
26+
break;
27+
case "_FSFTID": case "_FID": case "FSFTID":
28+
s.uri = "https://gedcom.io/terms/v7/EXID";
29+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "https://www.familysearch.org/tree/person/");
30+
break;
31+
case "_APID":
32+
s.uri = "https://gedcom.io/terms/v7/EXID";
33+
new GedStruct(s, "https://gedcom.io/terms/v7/TYPE", "https://www.ancestry.com/family-tree/");
34+
break;
35+
// case "HISTID": // unclear what TYPE to give it
36+
default: changed = false;
37+
}
38+
if (changed) s.tag2uri(false);
39+
for(GedStruct s2 : s.sub) update(s2);
40+
return null;
41+
}
42+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package edu.virginia.ged5to7.pipeline;
2+
import edu.virginia.ged5to7.GedStruct;
3+
4+
public class RenameFilter implements Filter {
5+
public java.util.Collection<GedStruct> update(GedStruct s) {
6+
if ("EMAI".equals(s.tag) || "_EMAIL".equals(s.tag)) {
7+
s.uri = "https://gedcom.io/terms/v7/EMAIL";
8+
s.tag2uri(false);
9+
} else if ("TYPE".equals(s.tag) && s.sup != null && "https://gedcom.io/terms/v7/FORM".equals(s.sup.uri)) {
10+
s.uri = "https://gedcom.io/terms/v7/MEDI";
11+
s.tag2uri(false);
12+
} else if ("_UID".equals(s.tag)) {
13+
s.uri = "https://gedcom.io/terms/v7/UID";
14+
s.tag2uri(false);
15+
} else if ("_ASSO".equals(s.tag)) {
16+
if (s.pointsTo == null) {
17+
new GedStruct(s, "https://gedcom.io/terms/v7/PHRASE", s.payload);
18+
s.pointsTo = GedStruct.VOID;
19+
}
20+
s.uri = "https://gedcom.io/terms/v7/ASSO";
21+
s.tag2uri(false);
22+
} else if ("_CRE".equals(s.tag) || "_CREAT".equals(s.tag)) {
23+
s.uri = "https://gedcom.io/terms/v7/CREA";
24+
s.tag2uri(false);
25+
} else if ("_DATE".equals(s.tag)) {
26+
s.tag = "DATE"; // needed for AgeDateFilter
27+
s.uri = "https://gedcom.io/terms/v7/DATE";
28+
s.tag2uri(false);
29+
} else if ("RELA".equals(s.tag) && s.sup != null && "https://gedcom.io/terms/v7/ASSO".equals(s.sup.uri)) {
30+
s.uri = "https://gedcom.io/terms/v7/ROLE";
31+
s.tag2uri(false);
32+
}
33+
34+
for(GedStruct s2 : s.sub) update(s2);
35+
return null;
36+
}
37+
}

0 commit comments

Comments
 (0)