glossarist 0.4.13 → 0.4.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/rdf/sections-builder.js +16 -9
package/package.json
CHANGED
|
@@ -100,11 +100,17 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
const subjectStr = subject.value;
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
// Compact classId and classLabel to CURIE form for UI consumers.
|
|
104
|
+
// The Vue components compare against CURIEs ('gloss:Concept') not
|
|
105
|
+
// absolute IRIs, so the builder is responsible for the conversion.
|
|
106
|
+
const rawClassId = types.length > 0 ? types[0] : '';
|
|
107
|
+
const classId = rawClassId ? compactIri(rawClassId) : '';
|
|
108
|
+
const classLabel = deriveClassLabel(rawClassId);
|
|
105
109
|
const label = prefLabel?.value ?? rdfsLabel ?? deriveSubjectLabel(subjectStr);
|
|
106
110
|
|
|
107
|
-
// Group predicates (preserve insertion order)
|
|
111
|
+
// Group predicates (preserve insertion order). Compact IRIs to CURIEs
|
|
112
|
+
// for display — UI consumers expect 'gloss:hasDefinition' rather than
|
|
113
|
+
// 'https://www.glossarist.org/ontologies/hasDefinition'.
|
|
108
114
|
const props = [];
|
|
109
115
|
const seenPredKeys = new Set();
|
|
110
116
|
|
|
@@ -112,11 +118,12 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
|
|
|
112
118
|
const isBnodeObj = q.object.termType === 'BlankNode';
|
|
113
119
|
const formatted = formatTerm(q.object, bnodeQuads);
|
|
114
120
|
if (formatted === '') continue;
|
|
115
|
-
const
|
|
121
|
+
const predicate = compactIri(q.predicate.value);
|
|
122
|
+
const dedupKey = `${predicate}#${isBnodeObj ? 'n' : 'f'}#${formatted}`;
|
|
116
123
|
if (seenPredKeys.has(dedupKey)) continue;
|
|
117
124
|
seenPredKeys.add(dedupKey);
|
|
118
125
|
|
|
119
|
-
const prop = { predicate
|
|
126
|
+
const prop = { predicate, values: [formatted] };
|
|
120
127
|
if (isBnodeObj) prop.nested = true;
|
|
121
128
|
props.push(prop);
|
|
122
129
|
}
|
|
@@ -132,7 +139,7 @@ function resourceToClassInstance(subject, quads, bnodeQuads, language) {
|
|
|
132
139
|
function formatTerm(term, bnodeQuads) {
|
|
133
140
|
switch (term.termType) {
|
|
134
141
|
case 'NamedNode':
|
|
135
|
-
return term.value;
|
|
142
|
+
return compactIri(term.value);
|
|
136
143
|
case 'Literal':
|
|
137
144
|
return term.value;
|
|
138
145
|
case 'BlankNode': {
|
|
@@ -151,11 +158,11 @@ function formatTerm(term, bnodeQuads) {
|
|
|
151
158
|
|
|
152
159
|
function deriveClassLabel(classId) {
|
|
153
160
|
if (!classId) return '';
|
|
154
|
-
// CURIE
|
|
155
|
-
if (
|
|
161
|
+
// ClassId is now CURIE form (compacted). Just take the local part.
|
|
162
|
+
if (classId.includes(':') && !classId.includes('://')) {
|
|
156
163
|
return classId.slice(classId.indexOf(':') + 1);
|
|
157
164
|
}
|
|
158
|
-
//
|
|
165
|
+
// Fallback for absolute IRIs that didn't compact
|
|
159
166
|
const noFrag = classId.split('#').pop();
|
|
160
167
|
const last = noFrag.split('/').pop();
|
|
161
168
|
return last || classId;
|