glossarist 0.4.39 → 0.4.40
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/designation.ts +297 -0
- package/src/models/gcr-metadata.ts +118 -0
- package/src/models/gcr-statistics.ts +76 -0
- package/src/models/hyperedge-colors.ts +87 -0
- package/src/models/register.ts +315 -0
- package/src/models/relation-categories.ts +167 -0
- package/src/models/{relation-colors.js → relation-colors.ts} +36 -23
- package/src/models/section.ts +61 -0
- package/src/models/designation.js +0 -213
- package/src/models/gcr-metadata.js +0 -68
- package/src/models/gcr-statistics.js +0 -51
- package/src/models/hyperedge-colors.js +0 -71
- package/src/models/register.js +0 -253
- package/src/models/relation-categories.js +0 -182
- package/src/models/section.js +0 -44
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
// Categorization SSOT for the 52 glossarist relationship types.
|
|
2
|
-
//
|
|
3
|
-
// Each type in RELATIONSHIP_TYPES belongs to exactly one category. The
|
|
4
|
-
// categories mirror the concept-model taxonomy
|
|
5
|
-
// (concept-browser:src/data/taxonomies.json) so JS consumers and the
|
|
6
|
-
// Vue UI see the same buckets. Adding a new type means adding a
|
|
7
|
-
// taxonomy entry — no code changes here.
|
|
8
|
-
//
|
|
9
|
-
// The 8 categories:
|
|
10
|
-
// lifecycle — supersession, deprecation, replacement
|
|
11
|
-
// hierarchical — SKOS + ISO 25964 broader/narrower (generic/partitive/instantial)
|
|
12
|
-
// associative — generic see-also references
|
|
13
|
-
// comparative — compare / contrast
|
|
14
|
-
// spatiotemporal — sequential, spatial, temporal
|
|
15
|
-
// lexical — homograph, false_friend (cross-language)
|
|
16
|
-
// mapping — SKOS mapping properties (cross-vocabulary)
|
|
17
|
-
// definitional — ISO 19135 concept-to-concept relations: definition, part,
|
|
18
|
-
// instance, inheritance, versioning
|
|
19
|
-
//
|
|
20
|
-
// Designation-level relationships (abbreviated_form_for, short_form_for)
|
|
21
|
-
// are a separate concern — see DESIGNATION_RELATIONSHIP_TYPES.
|
|
22
|
-
|
|
23
|
-
import { RELATIONSHIP_TYPES } from './related-concept.js';
|
|
24
|
-
|
|
25
|
-
// Category definitions. The `types` array is the exhaustive list of
|
|
26
|
-
// relationship-type local names that fall into the category. Each type
|
|
27
|
-
// must appear in exactly one category (verified by MECE test).
|
|
28
|
-
export const RELATION_CATEGORIES = Object.freeze({
|
|
29
|
-
lifecycle: Object.freeze({
|
|
30
|
-
label: 'Lifecycle',
|
|
31
|
-
description: 'Concept lifecycle transitions: supersession, deprecation, replacement.',
|
|
32
|
-
types: Object.freeze([
|
|
33
|
-
'deprecates', 'deprecated_by',
|
|
34
|
-
'supersedes', 'superseded_by',
|
|
35
|
-
'replaces', 'replaced_by',
|
|
36
|
-
'invalidates', 'invalidated_by',
|
|
37
|
-
'retires', 'retired_by',
|
|
38
|
-
]),
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
hierarchical: Object.freeze({
|
|
42
|
-
label: 'Hierarchical',
|
|
43
|
-
description: 'Broader/narrower relations, including SKOS and ISO 25964 generic/partitive/instantial.',
|
|
44
|
-
types: Object.freeze([
|
|
45
|
-
'broader', 'narrower',
|
|
46
|
-
'broader_generic', 'narrower_generic',
|
|
47
|
-
'broader_partitive', 'narrower_partitive',
|
|
48
|
-
'broader_instantial', 'narrower_instantial',
|
|
49
|
-
]),
|
|
50
|
-
}),
|
|
51
|
-
|
|
52
|
-
associative: Object.freeze({
|
|
53
|
-
label: 'Associative',
|
|
54
|
-
description: 'Generic see-also references between concepts.',
|
|
55
|
-
types: Object.freeze([
|
|
56
|
-
'see', 'related_concept',
|
|
57
|
-
'related_concept_broader', 'related_concept_narrower',
|
|
58
|
-
'references',
|
|
59
|
-
]),
|
|
60
|
-
}),
|
|
61
|
-
|
|
62
|
-
comparative: Object.freeze({
|
|
63
|
-
label: 'Comparative',
|
|
64
|
-
description: 'Compare / contrast relations between concepts.',
|
|
65
|
-
types: Object.freeze(['compare', 'contrast']),
|
|
66
|
-
}),
|
|
67
|
-
|
|
68
|
-
spatiotemporal: Object.freeze({
|
|
69
|
-
label: 'Spatiotemporal',
|
|
70
|
-
description: 'Sequential, spatial, and temporal relations.',
|
|
71
|
-
types: Object.freeze([
|
|
72
|
-
'sequentially_related_concept',
|
|
73
|
-
'spatially_related_concept',
|
|
74
|
-
'temporally_related_concept',
|
|
75
|
-
]),
|
|
76
|
-
}),
|
|
77
|
-
|
|
78
|
-
lexical: Object.freeze({
|
|
79
|
-
label: 'Lexical',
|
|
80
|
-
description: 'Lexical relations between designations across languages.',
|
|
81
|
-
types: Object.freeze(['homograph', 'false_friend']),
|
|
82
|
-
}),
|
|
83
|
-
|
|
84
|
-
mapping: Object.freeze({
|
|
85
|
-
label: 'Mapping',
|
|
86
|
-
description: 'SKOS mapping properties for cross-vocabulary alignment.',
|
|
87
|
-
types: Object.freeze([
|
|
88
|
-
'equivalent', 'close_match',
|
|
89
|
-
'broad_match', 'narrow_match', 'related_match',
|
|
90
|
-
]),
|
|
91
|
-
}),
|
|
92
|
-
|
|
93
|
-
// ISO 19135 concept-to-concept relations. Replaces the previous
|
|
94
|
-
// `conceptInstance` and `versioning` split — concept-browser's
|
|
95
|
-
// taxonomy treats versioning as part of the definitional cluster
|
|
96
|
-
// (a version IS a definitional variant of the same concept identity).
|
|
97
|
-
// Renaming aligns glossarist-js with the canonical taxonomy at
|
|
98
|
-
// concept-browser:src/data/taxonomies.json.
|
|
99
|
-
//
|
|
100
|
-
// `provides` / `provided_by` (Glossarist v2 extension) live here too:
|
|
101
|
-
// they record ExternalConcept resolution — a definitional linkage
|
|
102
|
-
// between a placeholder and the concept that fills its substance.
|
|
103
|
-
// See TODO.partitive-relation-v2 item 07.
|
|
104
|
-
definitional: Object.freeze({
|
|
105
|
-
label: 'Definitional',
|
|
106
|
-
description: 'ISO 19135 concept-to-concept relations: definition, part, instance, inheritance, versioning.',
|
|
107
|
-
types: Object.freeze([
|
|
108
|
-
'has_concept', 'is_concept_of',
|
|
109
|
-
'instance_of', 'has_instance',
|
|
110
|
-
'has_definition', 'definition_of',
|
|
111
|
-
'has_part', 'is_part_of',
|
|
112
|
-
'inherits', 'inherited_by',
|
|
113
|
-
'has_version', 'version_of',
|
|
114
|
-
'current_version', 'current_version_of',
|
|
115
|
-
'provides', 'provided_by',
|
|
116
|
-
]),
|
|
117
|
-
}),
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Reverse index built once. Maps each type local name to its category.
|
|
121
|
-
const _CATEGORY_BY_TYPE = (() => {
|
|
122
|
-
const map = new Map();
|
|
123
|
-
for (const [cat, def] of Object.entries(RELATION_CATEGORIES)) {
|
|
124
|
-
for (const t of def.types) map.set(t, cat);
|
|
125
|
-
}
|
|
126
|
-
return map;
|
|
127
|
-
})();
|
|
128
|
-
|
|
129
|
-
// Backward-compat aliases for callers that adopted the original
|
|
130
|
-
// glossarist-js naming (v0.4.6). Resolved at lookup time so any of
|
|
131
|
-
// the three names returns the definitional category.
|
|
132
|
-
const _CATEGORY_ALIASES = {
|
|
133
|
-
conceptInstance: 'definitional',
|
|
134
|
-
versioning: 'definitional',
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Returns the category key for the given relationship type, or null
|
|
139
|
-
* when the type is not categorized (e.g. an unrecognized custom type).
|
|
140
|
-
*/
|
|
141
|
-
export function categoryOf(type) {
|
|
142
|
-
return _CATEGORY_BY_TYPE.get(type) ?? null;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Returns the category definition ({ label, description, types }) for
|
|
147
|
-
* the given category key. Accepts both canonical names (definitional)
|
|
148
|
-
* and aliases from earlier glossarist-js versions (conceptInstance,
|
|
149
|
-
* versioning) for backward compatibility.
|
|
150
|
-
*/
|
|
151
|
-
export function categoryDefinition(categoryKey) {
|
|
152
|
-
const canonical = _CATEGORY_ALIASES[categoryKey] ?? categoryKey;
|
|
153
|
-
return RELATION_CATEGORIES[canonical] ?? null;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* MECE sanity check. Returns the list of relationship types that are
|
|
158
|
-
* NOT categorized (i.e. present in RELATIONSHIP_TYPES but missing from
|
|
159
|
-
* RELATION_CATEGORIES). Used by the test suite to verify SSOT drift.
|
|
160
|
-
*/
|
|
161
|
-
export function uncategorizedTypes() {
|
|
162
|
-
return RELATIONSHIP_TYPES.filter(t => !_CATEGORY_BY_TYPE.has(t));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* MECE sanity check. Returns a list of { type, categories } entries
|
|
167
|
-
* for any type that appears in MORE than one category. Should be
|
|
168
|
-
* empty when the categorization is mutually exclusive.
|
|
169
|
-
*/
|
|
170
|
-
export function duplicatedTypes() {
|
|
171
|
-
const counts = new Map();
|
|
172
|
-
for (const def of Object.values(RELATION_CATEGORIES)) {
|
|
173
|
-
for (const t of def.types) {
|
|
174
|
-
counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
const out = [];
|
|
178
|
-
for (const [type, count] of counts) {
|
|
179
|
-
if (count > 1) out.push({ type, count });
|
|
180
|
-
}
|
|
181
|
-
return out;
|
|
182
|
-
}
|
package/src/models/section.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { GlossaristModel } from './base.js';
|
|
2
|
-
|
|
3
|
-
export const ORDERING_METHODS = Object.freeze([
|
|
4
|
-
'systematic',
|
|
5
|
-
'mixed',
|
|
6
|
-
'alphabetical',
|
|
7
|
-
]);
|
|
8
|
-
|
|
9
|
-
export class Section extends GlossaristModel {
|
|
10
|
-
constructor(data = {}) {
|
|
11
|
-
super();
|
|
12
|
-
this.id = data.id ?? null;
|
|
13
|
-
this.names = data.names ?? {};
|
|
14
|
-
this.ordering = data.ordering ?? null;
|
|
15
|
-
this.children = (data.children ?? []).map(c =>
|
|
16
|
-
c instanceof Section ? c : new Section(c)
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
name(lang) {
|
|
21
|
-
return this.names[lang] ?? this.names.eng ?? null;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
descendantById(id) {
|
|
25
|
-
for (const child of this.children) {
|
|
26
|
-
if (child.id === id) return child;
|
|
27
|
-
const found = child.descendantById(id);
|
|
28
|
-
if (found) return found;
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
toJSON() {
|
|
34
|
-
const obj = { id: this.id };
|
|
35
|
-
if (Object.keys(this.names).length > 0) obj.names = { ...this.names };
|
|
36
|
-
if (this.ordering != null) obj.ordering = this.ordering;
|
|
37
|
-
if (this.children.length > 0) obj.children = this.children.map(c => c.toJSON());
|
|
38
|
-
return obj;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
static fromJSON(data) {
|
|
42
|
-
return new Section(data);
|
|
43
|
-
}
|
|
44
|
-
}
|