Skip to content

Commit

Permalink
feat(etl): add museum data from museum authority list
Browse files Browse the repository at this point in the history
  • Loading branch information
jmiguelv committed Jan 14, 2025
1 parent 6cce51c commit 55839ab
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/etl/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ async function processTeiFiles(inputPath, outputPath, options = {}) {
delete result.provenanceFound;
delete result.provenanceObserved;
delete result.provenanceLost;
delete result.repository.museum;
delete result.bibliographyEdition;
delete result.bibliographyDiscussion;

Expand Down
20 changes: 19 additions & 1 deletion packages/etl/src/metadata.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import xml2js from "xml2js";
import museums from "../../../data/processed/museums.json" assert { type: "json" };

/**
* Extracts metadata from an XML string.
Expand Down Expand Up @@ -312,11 +313,28 @@ function getMsIdentifier(xml) {
country: msIdentifier.country?.trim(),
region: msIdentifier.region?.trim(),
settlement: msIdentifier.settlement?.trim(),
repository: msIdentifier.repository,
repository: getRepository(msIdentifier),
idno: msIdentifier.idno,
};
}

function getRepository(msIdentifier) {
const ref = msIdentifier.repository?.ref;

if (!ref) return msIdentifier.repository;

const museum = museums.find((m) => m.uri === ref);

if (!museum) return msIdentifier.repository;

return {
_: museum.name,
role: museum.type,
ref: museum.uri,
museum,
};
}

function getTextLang(xml) {
const textLang =
xml.TEI.teiHeader.fileDesc.sourceDesc.msDesc.msContents.textLang;
Expand Down

0 comments on commit 55839ab

Please # to comment.