glossarist 0.4.26 → 0.4.27
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
CHANGED
|
@@ -198,6 +198,16 @@ function definitionLabel(d) {
|
|
|
198
198
|
return d.content ?? '?';
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
import { multiplicityFromPair } from '../models/multiplicity.js';
|
|
202
|
+
|
|
203
|
+
function _resolveMultiplicity(m) {
|
|
204
|
+
if (m?.presence && m?.count) {
|
|
205
|
+
try { return multiplicityFromPair(m.presence, m.count); }
|
|
206
|
+
catch { return 'compulsory'; }
|
|
207
|
+
}
|
|
208
|
+
return m?.multiplicity ?? 'compulsory';
|
|
209
|
+
}
|
|
210
|
+
|
|
201
211
|
function relationLabel(r) {
|
|
202
212
|
if (!r) return '?';
|
|
203
213
|
const c = r.comprehensive;
|
|
@@ -206,7 +216,7 @@ function relationLabel(r) {
|
|
|
206
216
|
? r.partitives.map(m => {
|
|
207
217
|
const ref = m?.ref ?? m ?? {};
|
|
208
218
|
let tail = '';
|
|
209
|
-
const mult = m
|
|
219
|
+
const mult = _resolveMultiplicity(m);
|
|
210
220
|
if (mult && mult !== 'compulsory') tail = ` (${mult})`;
|
|
211
221
|
if (m?.is_delimiting === true) tail += ' ⊘';
|
|
212
222
|
return `${ref.id ?? ref.source ?? ref.text ?? '?'}${tail}`;
|
|
@@ -236,7 +246,7 @@ export function multiplicityStats(relations) {
|
|
|
236
246
|
for (const rel of relations ?? []) {
|
|
237
247
|
for (const m of rel?.partitives ?? []) {
|
|
238
248
|
total += 1;
|
|
239
|
-
const mult = m
|
|
249
|
+
const mult = _resolveMultiplicity(m);
|
|
240
250
|
byMultiplicity[mult] = (byMultiplicity[mult] ?? 0) + 1;
|
|
241
251
|
const p = m?.presence ?? 'required';
|
|
242
252
|
const c = m?.count ?? 'exactly_one';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// ISO 704:2022 correction):
|
|
9
9
|
//
|
|
10
10
|
// comprehensive → comprehensive (unchanged shape)
|
|
11
|
-
// parts: [ref, ...] → partitives: [{ ref,
|
|
11
|
+
// parts: [ref, ...] → partitives: [{ ref, presence: 'required', count: 'exactly_one' }, ...]
|
|
12
12
|
// enumeration: open → completeness: partial
|
|
13
13
|
// enumeration: closed→ completeness: complete
|
|
14
14
|
// markers: [...] → (dropped — v2 uses per-member multiplicity
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
import { PRED } from './predicates.js';
|
|
23
23
|
import { namedNode, literal, quad } from './terms.js';
|
|
24
|
+
import { multiplicityFromPair } from '../models/multiplicity.js';
|
|
24
25
|
|
|
25
26
|
// SKOS taxonomy namespaces (concept-model will ship these taxonomies).
|
|
26
27
|
// Until then, the URIs are forward-compatible and resolve once the
|
|
@@ -45,11 +46,16 @@ export function* partitiveMemberToQuads(member, { memberUri }) {
|
|
|
45
46
|
);
|
|
46
47
|
}
|
|
47
48
|
// Derived multiplicity URI for v3 RDF consumer backward compat.
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
// v4 PartitiveMember no longer exposes .multiplicity — compute from
|
|
50
|
+
// presence + count via multiplicityFromPair. Accept raw JSON that
|
|
51
|
+
// still carries a literal multiplicity field for pre-v4 data.
|
|
52
|
+
let mult = null;
|
|
53
|
+
if (member?.presence && member?.count) {
|
|
54
|
+
try { mult = multiplicityFromPair(member.presence, member.count); }
|
|
55
|
+
catch { /* invalid combination — skip derived emission */ }
|
|
56
|
+
} else if (typeof member?.multiplicity === 'string') {
|
|
57
|
+
mult = member.multiplicity;
|
|
58
|
+
}
|
|
53
59
|
if (mult) {
|
|
54
60
|
yield quad(
|
|
55
61
|
namedNode(memberUri),
|