Skip to content

Commit 8e54ef2

Browse files
committed
updated authorty for Animalia
see plazi/names_LOD#154 (comment)
1 parent 4248d9b commit 8e54ef2

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/gg2rdf.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -562,17 +562,26 @@ export function gg2rdf(
562562

563563
authority = normalizeAuthority(authority);
564564
if (baseAuthority) {
565+
// ensures the baseAuthority is not present twice
565566
authority = authority.replaceAll(
566567
new RegExp(`\\(?${baseAuthority}\\)?[,:;\\s]*`, "g"),
567568
"",
568569
);
569570
}
570571
}
571572
if (baseAuthority && authority) {
572-
s.addProperty(
573-
"dwc:scientificNameAuthorship",
574-
STR(baseAuthority + " " + authority),
575-
);
573+
// Animalia has baseAuthority only in this case, all other Kingdoms get both.
574+
if (getKingdom(cTaxon) === "Animalia") {
575+
s.addProperty(
576+
"dwc:scientificNameAuthorship",
577+
STR(baseAuthority),
578+
);
579+
} else {
580+
s.addProperty(
581+
"dwc:scientificNameAuthorship",
582+
STR(baseAuthority + " " + authority),
583+
);
584+
}
576585
} else if (baseAuthority) {
577586
s.addProperty(
578587
"dwc:scientificNameAuthorship",
@@ -1241,13 +1250,19 @@ export function gg2rdf(
12411250
);
12421251
}
12431252

1253+
/** Get kingdom of taxonName
1254+
*
1255+
* If `taxonName.getAttribute("kingdom")` is falsy (e.g. null or empty), returns "Animalia".
1256+
*/
1257+
function getKingdom(taxonName: Element) {
1258+
return taxonName.getAttribute("kingdom") || "Animalia";
1259+
}
1260+
12441261
/** returns plain uri
12451262
*
12461263
* replaces <xsl:call-template name="taxonConceptBaseURI"> */
12471264
function taxonConceptBaseURI({ kingdom }: { kingdom: string }) {
1248-
return `http://taxon-concept.plazi.org/id/${
1249-
kingdom ? partialURI(kingdom) : "Animalia"
1250-
}`;
1265+
return `http://taxon-concept.plazi.org/id/${kingdom}`;
12511266
}
12521267

12531268
/** returns valid turtle uri
@@ -1260,7 +1275,7 @@ export function gg2rdf(
12601275
},
12611276
) {
12621277
return URI(
1263-
taxonConceptBaseURI({ kingdom: taxonName.getAttribute("kingdom") }) +
1278+
taxonConceptBaseURI({ kingdom: getKingdom(taxonName) }) +
12641279
taxonNameForURI(taxonName) + taxonAuthority,
12651280
);
12661281
}

0 commit comments

Comments
 (0)