glossarist 0.4.34 → 0.4.35
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/models/concept-system-type.js +26 -0
- package/src/models/concept-system.js +117 -0
- package/src/models/concept-type.js +25 -0
- package/src/models/equivalence-degree.js +25 -0
- package/src/models/sequential-hyperedge.js +56 -0
- package/src/models/sequential-member.js +13 -0
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// ConceptSystemType — ISO 12620 A.7.1 concept system type enum.
|
|
2
|
+
//
|
|
3
|
+
// Permissible instances per ISO 12620:
|
|
4
|
+
// generic — species are part of the extension of the genus
|
|
5
|
+
// partitive — based on whole-part relations
|
|
6
|
+
// sequential — based on spatial and temporal relations
|
|
7
|
+
// associative — based on thematic or pragmatic relations
|
|
8
|
+
// mixed — two or more of the above (the realistic case)
|
|
9
|
+
|
|
10
|
+
export const CONCEPT_SYSTEM_TYPE = Object.freeze({
|
|
11
|
+
GENERIC: 'generic',
|
|
12
|
+
PARTITIVE: 'partitive',
|
|
13
|
+
SEQUENTIAL: 'sequential',
|
|
14
|
+
ASSOCIATIVE: 'associative',
|
|
15
|
+
MIXED: 'mixed',
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export const CONCEPT_SYSTEM_TYPE_VALUES = Object.freeze(
|
|
19
|
+
Object.values(CONCEPT_SYSTEM_TYPE),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export function isValidConceptSystemType(value) {
|
|
23
|
+
return CONCEPT_SYSTEM_TYPE_VALUES.includes(value);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default CONCEPT_SYSTEM_TYPE;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// ConceptSystem — first-class concept system entity per ISO 12620 A.7.
|
|
2
|
+
//
|
|
3
|
+
// Promotes the previously-implicit concept system (domains + tags +
|
|
4
|
+
// relation graph) to an explicit first-class entity. Per-file at
|
|
5
|
+
// `concept-systems/<id>.yaml`.
|
|
6
|
+
//
|
|
7
|
+
// See docs/design/concept-systems.md (concept-model repo).
|
|
8
|
+
|
|
9
|
+
import { GlossaristModel } from './base.js';
|
|
10
|
+
import { ConceptRef } from './concept-ref.js';
|
|
11
|
+
import {
|
|
12
|
+
CONCEPT_SYSTEM_TYPE,
|
|
13
|
+
CONCEPT_SYSTEM_TYPE_VALUES,
|
|
14
|
+
isValidConceptSystemType,
|
|
15
|
+
} from './concept-system-type.js';
|
|
16
|
+
|
|
17
|
+
export class ConceptSystem extends GlossaristModel {
|
|
18
|
+
constructor(data = {}) {
|
|
19
|
+
super();
|
|
20
|
+
this.id = _ensureNonEmptyString(data.id, 'id');
|
|
21
|
+
this.name = _ensureName(data.name);
|
|
22
|
+
this.type = _resolveType(data.type);
|
|
23
|
+
this.domain = data.domain ?? null;
|
|
24
|
+
this.purpose = data.purpose ?? null;
|
|
25
|
+
this.members = _ensureMembers(data.members);
|
|
26
|
+
this.hyperedges = Array.isArray(data.hyperedges) ? [...data.hyperedges] : [];
|
|
27
|
+
this.rootConcepts = Array.isArray(data.rootConcepts)
|
|
28
|
+
? data.rootConcepts.map(c => c instanceof ConceptRef ? c : new ConceptRef(c))
|
|
29
|
+
: [];
|
|
30
|
+
this.sources = Array.isArray(data.sources) ? [...data.sources] : [];
|
|
31
|
+
this.status = data.status ?? null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get isGeneric() { return this.type === CONCEPT_SYSTEM_TYPE.GENERIC; }
|
|
35
|
+
get isPartitive() { return this.type === CONCEPT_SYSTEM_TYPE.PARTITIVE; }
|
|
36
|
+
get isSequential() { return this.type === CONCEPT_SYSTEM_TYPE.SEQUENTIAL; }
|
|
37
|
+
get isAssociative() { return this.type === CONCEPT_SYSTEM_TYPE.ASSOCIATIVE; }
|
|
38
|
+
get isMixed() { return this.type === CONCEPT_SYSTEM_TYPE.MIXED; }
|
|
39
|
+
|
|
40
|
+
hasHyperedge(edgeId) {
|
|
41
|
+
return this.hyperedges.includes(edgeId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
hasMember(refOrUri) {
|
|
45
|
+
const uri = typeof refOrUri === 'string' ? refOrUri : _refUri(refOrUri);
|
|
46
|
+
return this.members.some(m => _refUri(m) === uri);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
identity() {
|
|
50
|
+
return this.id;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON() {
|
|
54
|
+
const obj = {
|
|
55
|
+
id: this.id,
|
|
56
|
+
name: { ...this.name },
|
|
57
|
+
type: this.type,
|
|
58
|
+
members: this.members.map(m => m.toJSON()),
|
|
59
|
+
};
|
|
60
|
+
if (this.domain != null) obj.domain = this.domain;
|
|
61
|
+
if (this.purpose != null) obj.purpose = { ...this.purpose };
|
|
62
|
+
if (this.hyperedges.length > 0) obj.hyperedges = [...this.hyperedges];
|
|
63
|
+
if (this.rootConcepts.length > 0) obj.rootConcepts = this.rootConcepts.map(c => c.toJSON());
|
|
64
|
+
if (this.sources.length > 0) obj.sources = [...this.sources];
|
|
65
|
+
if (this.status != null) obj.status = this.status;
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static fromJSON(data) {
|
|
70
|
+
return new ConceptSystem(data);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function _ensureNonEmptyString(value, fieldName) {
|
|
75
|
+
if (typeof value !== 'string' || value.length === 0) {
|
|
76
|
+
throw new Error(`ConceptSystem#${fieldName} must be a non-empty string`);
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function _ensureName(value) {
|
|
82
|
+
if (value == null) return {};
|
|
83
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
84
|
+
throw new Error('ConceptSystem#name must be a localized object (e.g. { eng: "..." })');
|
|
85
|
+
}
|
|
86
|
+
return { ...value };
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function _resolveType(value) {
|
|
90
|
+
if (value == null) {
|
|
91
|
+
throw new Error(
|
|
92
|
+
'ConceptSystem#type is required; one of ' +
|
|
93
|
+
CONCEPT_SYSTEM_TYPE_VALUES.join(', '),
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (!isValidConceptSystemType(value)) {
|
|
97
|
+
throw new Error(
|
|
98
|
+
`ConceptSystem#type ${JSON.stringify(value)} invalid; ` +
|
|
99
|
+
`must be one of: ${CONCEPT_SYSTEM_TYPE_VALUES.join(', ')}`,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function _ensureMembers(values) {
|
|
106
|
+
if (!Array.isArray(values) || values.length === 0) {
|
|
107
|
+
throw new Error('ConceptSystem#members must be a non-empty array');
|
|
108
|
+
}
|
|
109
|
+
return values.map(v => v instanceof ConceptRef ? v : new ConceptRef(v));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function _refUri(ref) {
|
|
113
|
+
const r = ref?.ref ?? ref ?? {};
|
|
114
|
+
return `${r.source ?? ''}:${r.id ?? ''}`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export default ConceptSystem;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ConceptType — ISO 704:2022 §5.2-5.3 general vs individual concept.
|
|
2
|
+
//
|
|
3
|
+
// general — concept corresponds to a category of objects
|
|
4
|
+
// (designated by terms or symbols)
|
|
5
|
+
// individual — concept corresponds to a unique object
|
|
6
|
+
// (designated by proper names / appellations)
|
|
7
|
+
//
|
|
8
|
+
// Individual concepts occupy the bottom rung of a concept ladder
|
|
9
|
+
// and cannot be subdivided into more specific concepts, but CAN be
|
|
10
|
+
// subdivided into parts via a partitive relation.
|
|
11
|
+
|
|
12
|
+
export const CONCEPT_TYPE = Object.freeze({
|
|
13
|
+
GENERAL: 'general',
|
|
14
|
+
INDIVIDUAL: 'individual',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const CONCEPT_TYPE_VALUES = Object.freeze(Object.values(CONCEPT_TYPE));
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_CONCEPT_TYPE = CONCEPT_TYPE.GENERAL;
|
|
20
|
+
|
|
21
|
+
export function isValidConceptType(value) {
|
|
22
|
+
return CONCEPT_TYPE_VALUES.includes(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default CONCEPT_TYPE;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// EquivalenceDegree — ISO 704:2022 §7.7.3 cross-language equivalence.
|
|
2
|
+
//
|
|
3
|
+
// full — equivalent intension across languages (default)
|
|
4
|
+
// partial — overlapping but not identical intension
|
|
5
|
+
// none — no corresponding concept in this language
|
|
6
|
+
// directional — monodirectional equivalence (see equivalence_note)
|
|
7
|
+
|
|
8
|
+
export const EQUIVALENCE_DEGREE = Object.freeze({
|
|
9
|
+
FULL: 'full',
|
|
10
|
+
PARTIAL: 'partial',
|
|
11
|
+
NONE: 'none',
|
|
12
|
+
DIRECTIONAL: 'directional',
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const EQUIVALENCE_DEGREE_VALUES = Object.freeze(
|
|
16
|
+
Object.values(EQUIVALENCE_DEGREE),
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_EQUIVALENCE_DEGREE = EQUIVALENCE_DEGREE.FULL;
|
|
20
|
+
|
|
21
|
+
export function isValidEquivalenceDegree(value) {
|
|
22
|
+
return EQUIVALENCE_DEGREE_VALUES.includes(value);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default EQUIVALENCE_DEGREE;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// SequentialHyperedge — an ISO 12620 A.6.3 / ISO 704:2022 §5.5.5
|
|
2
|
+
// sequential relation connecting a comprehensive concept to two or
|
|
3
|
+
// more subordinate concepts in an ORDERED sequence (temporal,
|
|
4
|
+
// spatial, causal, developmental).
|
|
5
|
+
//
|
|
6
|
+
// Mirror of PartitiveHyperedge and GenericHyperedge. Member array
|
|
7
|
+
// order IS significant — reversing the array reverses the sequence.
|
|
8
|
+
// Use cases: manufacturing process steps, biological life cycles,
|
|
9
|
+
// software release lifecycles, supply chain stages, geological eras.
|
|
10
|
+
//
|
|
11
|
+
// See docs/design/abstract-nary-relation.md (concept-model repo).
|
|
12
|
+
|
|
13
|
+
import { AbstractHyperedge } from './abstract-hyperedge.js';
|
|
14
|
+
import { SequentialMember } from './sequential-member.js';
|
|
15
|
+
import { HyperedgeRegistry } from './hyperedge-registry.js';
|
|
16
|
+
|
|
17
|
+
export class SequentialHyperedge extends AbstractHyperedge {
|
|
18
|
+
// Per-class metadata block — the OCP contract.
|
|
19
|
+
static wireKey = 'sequential_relations';
|
|
20
|
+
static typeTag = 'sequential_relation';
|
|
21
|
+
static rdfType = 'gloss:SequentialRelation';
|
|
22
|
+
static memberClass = SequentialMember;
|
|
23
|
+
static v1WireKeys = [];
|
|
24
|
+
static kindLabel = 'SEQ';
|
|
25
|
+
|
|
26
|
+
constructor(data = {}) {
|
|
27
|
+
super(data);
|
|
28
|
+
this.members = data?.members == null
|
|
29
|
+
? this.members
|
|
30
|
+
: (Array.isArray(data.members)
|
|
31
|
+
? data.members.map(m =>
|
|
32
|
+
m instanceof SequentialMember ? m : new SequentialMember(m))
|
|
33
|
+
: this.members);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static identityOf(value) {
|
|
37
|
+
const v = value ?? {};
|
|
38
|
+
const c = v.comprehensive ?? {};
|
|
39
|
+
// For sequential, member order IS significant — do NOT sort.
|
|
40
|
+
const memberKeys = Array.isArray(v.members)
|
|
41
|
+
? v.members.map(m => {
|
|
42
|
+
const r = m?.ref ?? m ?? {};
|
|
43
|
+
return `${r.source ?? ''}:${r.id ?? ''}`;
|
|
44
|
+
})
|
|
45
|
+
: [];
|
|
46
|
+
return `${c.source ?? ''}:${c.id ?? ''}|${memberKeys.join('|')}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromJSON(data) {
|
|
50
|
+
return new SequentialHyperedge(data);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default SequentialHyperedge;
|
|
55
|
+
|
|
56
|
+
HyperedgeRegistry.register(SequentialHyperedge);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SequentialMember — one member of a SequentialHyperedge. Inherits
|
|
2
|
+
// the MECE shape from HyperedgeMember. Distinct leaf class for type
|
|
3
|
+
// safety. Member array order IS significant for sequential hyperedges.
|
|
4
|
+
//
|
|
5
|
+
// See docs/design/abstract-nary-relation.md (concept-model repo).
|
|
6
|
+
|
|
7
|
+
import { HyperedgeMember } from './hyperedge-member.js';
|
|
8
|
+
|
|
9
|
+
export class SequentialMember extends HyperedgeMember {
|
|
10
|
+
// Inherits all attributes and validations from HyperedgeMember.
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default SequentialMember;
|