glossarist 0.4.17 → 0.4.19
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/data/concept-model/shapes/glossarist.shacl.ttl +18 -0
- package/package.json +1 -1
- package/src/models/concept-source.js +4 -0
- package/src/models/index.d.ts +1 -0
- package/src/models/related-concept.js +33 -1
- package/src/rdf/gloss-source.js +9 -4
- package/src/rdf/predicates.d.ts +2 -0
- package/src/rdf/predicates.js +1 -0
|
@@ -391,6 +391,24 @@ gloss:ConceptSourceShape a sh:NodeShape ;
|
|
|
391
391
|
sh:path gloss:modification ;
|
|
392
392
|
sh:datatype xsd:string ;
|
|
393
393
|
sh:maxCount 1 ;
|
|
394
|
+
] ;
|
|
395
|
+
sh:property [
|
|
396
|
+
sh:path gloss:sourcedFrom ;
|
|
397
|
+
sh:class gloss:Citation ;
|
|
398
|
+
] ;
|
|
399
|
+
sh:sparql [
|
|
400
|
+
sh:message "sourced_from is only allowed on sources of type lineage"@en ;
|
|
401
|
+
sh:select """
|
|
402
|
+
PREFIX gloss: <https://www.glossarist.org/ontologies/>
|
|
403
|
+
PREFIX srctype: <https://www.glossarist.org/ontologies/srctype/>
|
|
404
|
+
SELECT $this
|
|
405
|
+
WHERE {
|
|
406
|
+
$this gloss:sourcedFrom ?target .
|
|
407
|
+
FILTER NOT EXISTS {
|
|
408
|
+
$this gloss:sourceType srctype:lineage .
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
""" ;
|
|
394
412
|
] .
|
|
395
413
|
|
|
396
414
|
gloss:ConceptDateShape a sh:NodeShape ;
|
package/package.json
CHANGED
|
@@ -11,6 +11,9 @@ export class ConceptSource extends GlossaristModel {
|
|
|
11
11
|
? (data.origin instanceof Citation ? data.origin : new Citation(data.origin))
|
|
12
12
|
: null;
|
|
13
13
|
this.modification = data.modification ?? null;
|
|
14
|
+
this.sourced_from = (data.sourced_from ?? []).map(
|
|
15
|
+
c => c instanceof Citation ? c : new Citation(c)
|
|
16
|
+
);
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
toJSON() {
|
|
@@ -20,6 +23,7 @@ export class ConceptSource extends GlossaristModel {
|
|
|
20
23
|
if (this.type != null) obj.type = this.type;
|
|
21
24
|
if (this.origin != null) obj.origin = this.origin.toJSON();
|
|
22
25
|
if (this.modification != null) obj.modification = this.modification;
|
|
26
|
+
if (this.sourced_from.length > 0) obj.sourced_from = this.sourced_from.map(c => c.toJSON());
|
|
23
27
|
return obj;
|
|
24
28
|
}
|
|
25
29
|
|
package/src/models/index.d.ts
CHANGED
|
@@ -257,6 +257,7 @@ export class ConceptSource extends GlossaristModel {
|
|
|
257
257
|
readonly type: string | null;
|
|
258
258
|
readonly origin: Citation | null;
|
|
259
259
|
readonly modification: string | null;
|
|
260
|
+
readonly sourced_from: Citation[];
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
export const RELATIONSHIP_TYPES: readonly string[];
|
|
@@ -37,12 +37,21 @@ export class RelatedConcept extends GlossaristModel {
|
|
|
37
37
|
constructor(data = {}) {
|
|
38
38
|
super();
|
|
39
39
|
this.type = data.type ?? 'see';
|
|
40
|
-
this.content = data.content
|
|
40
|
+
this.content = normalizeContent(data.content);
|
|
41
41
|
this.ref = data.ref
|
|
42
42
|
? (data.ref instanceof ConceptRef ? data.ref : new ConceptRef(data.ref))
|
|
43
43
|
: null;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// Convenience reader: returns the first available string value
|
|
47
|
+
// from the localized hash, or null if absent. Mirrors
|
|
48
|
+
// PartitiveHyperedge#contentString.
|
|
49
|
+
get contentString() {
|
|
50
|
+
if (!this.content) return null;
|
|
51
|
+
const values = Object.values(this.content);
|
|
52
|
+
return values.length > 0 ? values[0] : null;
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
toJSON() {
|
|
47
56
|
const obj = { type: this.type };
|
|
48
57
|
if (this.content != null) obj.content = this.content;
|
|
@@ -50,7 +59,30 @@ export class RelatedConcept extends GlossaristModel {
|
|
|
50
59
|
return obj;
|
|
51
60
|
}
|
|
52
61
|
|
|
62
|
+
static identityOf(value) {
|
|
63
|
+
const v = value ?? {};
|
|
64
|
+
const ref = v?.ref;
|
|
65
|
+
return `${v.type ?? ''}|${ref?.source ?? ''}|${ref?.id ?? ''}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
identity() {
|
|
69
|
+
return RelatedConcept.identityOf(this);
|
|
70
|
+
}
|
|
71
|
+
|
|
53
72
|
static fromJSON(data) {
|
|
54
73
|
return new RelatedConcept(data);
|
|
55
74
|
}
|
|
56
75
|
}
|
|
76
|
+
|
|
77
|
+
// Content is a localized string (language → text). Plain strings on
|
|
78
|
+
// input are normalized to `{ default: '...' }` so callers always see
|
|
79
|
+
// the same shape. Mirrors PartitiveHyperedge's normalizeContent.
|
|
80
|
+
function normalizeContent(value) {
|
|
81
|
+
if (value == null) return null;
|
|
82
|
+
if (typeof value === 'string') return { default: value };
|
|
83
|
+
if (typeof value === 'object') {
|
|
84
|
+
const entries = Object.entries(value).filter(([, v]) => typeof v === 'string');
|
|
85
|
+
return entries.length > 0 ? Object.fromEntries(entries) : null;
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
package/src/rdf/gloss-source.js
CHANGED
|
@@ -27,13 +27,18 @@ export function* conceptSourceToQuads(source, { subjectUri, index }) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
if (source.origin) {
|
|
30
|
-
yield* citationToQuads(source.origin, { subjectUri: srcSubject });
|
|
30
|
+
yield* citationToQuads(source.origin, { subjectUri: srcSubject, predicate: PRED.gloss.sourceOrigin, bnodeKey: 'origin' });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const sourcedFrom = source.sourced_from ?? [];
|
|
34
|
+
for (let i = 0; i < sourcedFrom.length; i++) {
|
|
35
|
+
yield* citationToQuads(sourcedFrom[i], { subjectUri: srcSubject, predicate: PRED.gloss.sourcedFrom, bnodeKey: 'sourced_from', index: i });
|
|
31
36
|
}
|
|
32
37
|
}
|
|
33
38
|
|
|
34
|
-
function* citationToQuads(citation, { subjectUri }) {
|
|
35
|
-
const citSubject = deterministicBnode(subjectUri,
|
|
36
|
-
yield quad(namedNode(subjectUri), namedNode(
|
|
39
|
+
function* citationToQuads(citation, { subjectUri, predicate, bnodeKey, index = 0 }) {
|
|
40
|
+
const citSubject = deterministicBnode(subjectUri, bnodeKey, index);
|
|
41
|
+
yield quad(namedNode(subjectUri), namedNode(predicate), namedNode(citSubject));
|
|
37
42
|
yield quad(namedNode(citSubject), namedNode(WELL_KNOWN.rdfType), namedNode(PRED.gloss.Citation));
|
|
38
43
|
|
|
39
44
|
if (citation.original) {
|
package/src/rdf/predicates.d.ts
CHANGED
|
@@ -104,6 +104,7 @@ export declare const PRED = {
|
|
|
104
104
|
"sourceId": "https://www.glossarist.org/ontologies/sourceId",
|
|
105
105
|
"sourceOrigin": "https://www.glossarist.org/ontologies/sourceOrigin",
|
|
106
106
|
"modification": "https://www.glossarist.org/ontologies/modification",
|
|
107
|
+
"sourcedFrom": "https://www.glossarist.org/ontologies/sourcedFrom",
|
|
107
108
|
"hasCitationRef": "https://www.glossarist.org/ontologies/hasCitationRef",
|
|
108
109
|
"hasCitationLocality": "https://www.glossarist.org/ontologies/hasCitationLocality",
|
|
109
110
|
"citationOriginal": "https://www.glossarist.org/ontologies/citationOriginal",
|
|
@@ -362,6 +363,7 @@ export type Predicate =
|
|
|
362
363
|
| "https://www.glossarist.org/ontologies/sourceId"
|
|
363
364
|
| "https://www.glossarist.org/ontologies/sourceOrigin"
|
|
364
365
|
| "https://www.glossarist.org/ontologies/modification"
|
|
366
|
+
| "https://www.glossarist.org/ontologies/sourcedFrom"
|
|
365
367
|
| "https://www.glossarist.org/ontologies/hasCitationRef"
|
|
366
368
|
| "https://www.glossarist.org/ontologies/hasCitationLocality"
|
|
367
369
|
| "https://www.glossarist.org/ontologies/citationOriginal"
|
package/src/rdf/predicates.js
CHANGED
|
@@ -104,6 +104,7 @@ export const PRED = {
|
|
|
104
104
|
"sourceId": "https://www.glossarist.org/ontologies/sourceId",
|
|
105
105
|
"sourceOrigin": "https://www.glossarist.org/ontologies/sourceOrigin",
|
|
106
106
|
"modification": "https://www.glossarist.org/ontologies/modification",
|
|
107
|
+
"sourcedFrom": "https://www.glossarist.org/ontologies/sourcedFrom",
|
|
107
108
|
"hasCitationRef": "https://www.glossarist.org/ontologies/hasCitationRef",
|
|
108
109
|
"hasCitationLocality": "https://www.glossarist.org/ontologies/hasCitationLocality",
|
|
109
110
|
"citationOriginal": "https://www.glossarist.org/ontologies/citationOriginal",
|