Skip to content

Commit 9848bd2

Browse files
committed
edited data fields and display
1 parent 196ea99 commit 9848bd2

3 files changed

Lines changed: 32 additions & 16 deletions

File tree

‎resources/js/search.js‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ function displayResults(results, page = 1, perPage = 20) {
7979
const formatValue = (val, key) => {
8080
if (!Array.isArray(val)) return val;
8181
const periodFields = ['title'];
82-
return periodFields.includes(key) ? val.join('. ') : val.join(', ');
82+
const semicolonFields = ['classification'];
83+
return periodFields.includes(key) ? val.join('. ') : semicolonFields.includes(key) ? val.join('; ') : val.join(', ');
8384
};
8485

8586
const titleFields = ['msItemTitle'];
@@ -102,19 +103,20 @@ function displayResults(results, page = 1, perPage = 20) {
102103

103104
return `
104105
<div class="result-item" style="padding:15px; border:1px solid #ddd; margin-bottom:10px; border-radius:5px;">
105-
${item.displayTitleEnglish ? `<p>${formatValue(item.displayTitleEnglish, 'displayTitleEnglish')} </p>` : ''}
106-
${item.wrightNum ? `<p>${formatValue(item.wrightNum, 'wrightNum')} </p>` : ''}
107106
108-
<p>URL: <a href="${msUrl}" target="_blank">${msUrl}</a></p>
107+
<p><strong></strong> ${formatValue(item.shelfmark, 'shelfmark') || ''}
108+
${item.wrightNum ? `[${formatValue(item.wrightNum, 'wrightNum')} ]` : ''}
109+
110+
</p>
111+
<p>URI: <a href="${msUrl}" target="_blank">${msUrl}</a></p>
109112
<p>${item.origDate ? `${formatValue(item.origDate, 'origDate')}` : ''}${item.origPlace ? ` | ${formatValue(item.origPlace, 'origPlace')}` : ''}</p>
110113
<p class="text-muted">
111-
${item.scriptLanguage ? `Script: ${item.scriptLanguage} | ` : ''}
112-
${item.material ? `| ${formatValue(item.material, 'material')} | ` : ''}
113-
${item.form ? ` ${formatValue(item.form, 'material')} | ` : ''}
114-
${item.extent ? `| ${formatValue(item.extent, 'extent')} | ` : ''}
114+
${item.scriptLanguage ? `Script: ${item.scriptLanguage} ` : ''}
115+
${item.material ? `| ${formatValue(item.material, 'material')} ` : ''}
116+
${item.form ? ` ${formatValue(item.form, 'material')} ` : ''}
117+
${item.extent ? `| ${formatValue(item.extent, 'extent')} ` : ''}
115118
</p>
116119
117-
<p><strong>Shelfmark:</strong> ${formatValue(item.shelfmark, 'shelfmark') || 'N/A'}</p>
118120
${item.classification ? `Classification: ${formatValue(item.classification, 'classification')}` : ''}
119121
120122
</div>

‎tei2json.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ def extract_json(tree):
134134
place_list = text_list(root, ".//tei:placeName")
135135
origin_place_list = text_list(root, ".//tei:origPlace")
136136

137-
# shelfmark: altIdentifier idno type=BL-Shelfmark or altIdentifier/ idno content
138-
shelfmarks = text_list(root, ".//tei:altIdentifier/tei:idno[@type='BL-Shelfmark'] | .//tei:altIdentifier/tei:idno | .//tei:msIdentifier//tei:idno[@type='BL-Shelfmark']")
137+
# shelfmark: altIdentifier idno type=BL-Shelfmark-display or altIdentifier/ idno content
138+
shelfmarks = text_list(root, ".//tei:altIdentifier/tei:idno[@type='BL-Shelfmark-display'] | .//tei:msIdentifier//tei:idno[@type='BL-Shelfmark-display']")
139139

140140
# Wright entry number: from msIdentifier/altIdentifier/idno[@type='Wright-BL-Roman']
141141
wright_num = first_text(root, ".//tei:msIdentifier//tei:altIdentifier//tei:idno[@type='Wright-BL-Roman']")
@@ -187,9 +187,14 @@ def extract_json(tree):
187187

188188
# extent: from physDesc/objectDesc/supportDesc/extent/measure (text or @quantity)
189189
extent = first_text(root, ".//tei:physDesc//tei:objectDesc//tei:supportDesc//tei:extent//tei:measure")
190-
191-
# classification: collect descs under listRelation or relation descs (e.g., "Old Testament")
192-
classification = text_list(root, ".//tei:listRelation//tei:relation/tei:desc | .//tei:listRelation//tei:desc | .//tei:listRelation//tei:relation/tei:desc")
190+
# classification: from head/listRelation[@type='Wright-BL-Taxonomy']/relation/desc
191+
classification = text_list(root, ".//tei:head//tei:listRelation[@type='Wright-BL-Taxonomy']//tei:relation//tei:desc")
192+
# Exclude classifications about composite manuscripts
193+
if classification:
194+
classification = [c for c in classification
195+
if not c.lower().startswith("this unit is ")
196+
and not c.lower().startswith("this composite")
197+
and not c.lower().startswith("this manuscript")]
193198

194199
# date: separate fields for each date type
195200
orig_dates = text_list(root, ".//tei:origDate")

‎teiParts2json.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,19 @@ def extract_json(tree, part_node=None):
204204
contents_note = first_text(root, ".//tei:head/tei:note[@type='contents-note']")
205205

206206
# classification: collect descs under listRelation or relation descs (e.g., "Old Testament")
207-
classification = text_list(root, ".//tei:listRelation//tei:relation/tei:desc | .//tei:listRelation//tei:desc | .//tei:listRelation//tei:relation/tei:desc")
207+
# classification = text_list(root, ".//tei:listRelation//tei:relation/tei:desc | .//tei:listRelation//tei:desc | .//tei:listRelation//tei:relation/tei:desc")
208+
209+
# classification: from head/listRelation[@type='Wright-BL-Taxonomy']/relation/desc
210+
classification = text_list(root, ".//tei:head/tei:listRelation[@type='Wright-BL-Taxonomy']/tei:relation/tei:desc")
211+
# Exclude classifications about composite manuscripts
212+
if classification:
213+
classification = [c for c in classification
214+
if not c.lower().startswith("this unit is a part of a composite manuscript")
215+
and not c.lower().startswith("this composite")
216+
and not c.lower().startswith("this manuscript")]
208217

209218
# date: separate fields for each date type
210-
orig_dates = text_list(root, ".//tei:origDate")
219+
orig_dates = first_text(root, ".//tei:origDate")
211220
date_not_before = text_list(root, ".//tei:origDate/@notBefore | .//tei:date/@notBefore")
212221
date_not_after = text_list(root, ".//tei:origDate/@notAfter | .//tei:date/@notAfter")
213222
date_when = text_list(root, ".//tei:date/@when")

0 commit comments

Comments
 (0)