glossarist 0.2.1 → 0.3.0
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/README.md +4 -2
- package/package.json +1 -1
- package/src/concept-parser.js +27 -0
- package/src/concept-serializer.js +16 -0
- package/src/gcr-reader.js +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/models/citation.js +48 -29
- package/src/models/concept-date.js +1 -1
- package/src/models/concept-ref.js +25 -0
- package/src/models/concept-reference.js +36 -0
- package/src/models/concept.js +23 -2
- package/src/models/designation.js +69 -14
- package/src/models/grammar-info.js +40 -0
- package/src/models/index.d.ts +117 -22
- package/src/models/index.js +7 -2
- package/src/models/locality.js +22 -0
- package/src/models/localized-concept.js +113 -10
- package/src/models/non-verb-rep.js +8 -8
- package/src/models/pronunciation.js +26 -0
- package/src/models/related-concept.js +25 -6
- package/src/reference-resolver.js +11 -1
- package/src/validators/index.js +26 -1
- package/src/validators/v3-rules.js +216 -0
package/src/models/index.d.ts
CHANGED
|
@@ -8,14 +8,17 @@ export class GlossaristModel {
|
|
|
8
8
|
export class Concept extends GlossaristModel {
|
|
9
9
|
readonly id: string;
|
|
10
10
|
readonly term: string | null;
|
|
11
|
+
readonly uri: string | null;
|
|
11
12
|
readonly termid: string;
|
|
12
13
|
readonly languages: string[];
|
|
13
14
|
readonly localizations: Record<string, any>;
|
|
14
15
|
readonly raw: Record<string, unknown> | null;
|
|
15
16
|
readonly relatedConcepts: RelatedConcept[];
|
|
17
|
+
readonly domains: ConceptReference[];
|
|
16
18
|
readonly dates: ConceptDate[];
|
|
17
19
|
readonly sources: ConceptSource[];
|
|
18
20
|
readonly status: string | null;
|
|
21
|
+
readonly schemaVersion: string | null;
|
|
19
22
|
|
|
20
23
|
localization(lang: string): LocalizedConcept | undefined;
|
|
21
24
|
primaryDesignation(lang: string): string | null;
|
|
@@ -27,13 +30,29 @@ export class Concept extends GlossaristModel {
|
|
|
27
30
|
|
|
28
31
|
export class LocalizedConcept extends GlossaristModel {
|
|
29
32
|
readonly languageCode: string | null;
|
|
33
|
+
readonly script: string | null;
|
|
34
|
+
readonly system: string | null;
|
|
35
|
+
readonly entryStatus: string | null;
|
|
36
|
+
readonly classification: string | null;
|
|
37
|
+
readonly reviewType: string | null;
|
|
38
|
+
readonly domain: string | null;
|
|
39
|
+
readonly release: string | null;
|
|
40
|
+
readonly lineageSourceSimilarity: number | null;
|
|
41
|
+
readonly reviewDate: string | null;
|
|
42
|
+
readonly reviewDecisionDate: string | null;
|
|
43
|
+
readonly reviewDecisionEvent: string | null;
|
|
44
|
+
readonly reviewStatus: string | null;
|
|
45
|
+
readonly reviewDecision: string | null;
|
|
46
|
+
readonly reviewDecisionNotes: string | null;
|
|
30
47
|
readonly terms: Designation[];
|
|
31
48
|
readonly definitions: DetailedDefinition[];
|
|
32
49
|
readonly definition: DetailedDefinition[];
|
|
33
|
-
readonly notes:
|
|
34
|
-
readonly examples:
|
|
50
|
+
readonly notes: DetailedDefinition[];
|
|
51
|
+
readonly examples: DetailedDefinition[];
|
|
35
52
|
readonly sources: ConceptSource[];
|
|
36
|
-
readonly
|
|
53
|
+
readonly dates: ConceptDate[];
|
|
54
|
+
readonly nonVerbalRep: NonVerbRep[];
|
|
55
|
+
readonly related: RelatedConcept[];
|
|
37
56
|
readonly primaryDesignation: string | null;
|
|
38
57
|
readonly primaryDefinition: string | null;
|
|
39
58
|
static fromJSON(data: Record<string, unknown>): LocalizedConcept;
|
|
@@ -43,35 +62,100 @@ export class Designation extends GlossaristModel {
|
|
|
43
62
|
readonly designation: string;
|
|
44
63
|
readonly type: string;
|
|
45
64
|
readonly normativeStatus: string | null;
|
|
65
|
+
readonly absent: boolean | null;
|
|
66
|
+
readonly fieldOfApplication: string | null;
|
|
67
|
+
readonly usageInfo: string | null;
|
|
68
|
+
readonly geographicalArea: string | null;
|
|
69
|
+
readonly language: string | null;
|
|
70
|
+
readonly script: string | null;
|
|
71
|
+
readonly system: string | null;
|
|
72
|
+
readonly international: boolean | null;
|
|
73
|
+
readonly termType: string | null;
|
|
74
|
+
readonly pronunciations: Pronunciation[];
|
|
75
|
+
readonly sources: ConceptSource[];
|
|
76
|
+
readonly related: RelatedConcept[];
|
|
46
77
|
static register(type: string, cls: typeof Designation): void;
|
|
47
78
|
static fromData(data: Record<string, unknown>): Designation;
|
|
48
79
|
static fromJSON(data: Record<string, unknown>): Designation;
|
|
49
80
|
}
|
|
50
81
|
|
|
51
82
|
export class Expression extends Designation {
|
|
83
|
+
readonly prefix: string | null;
|
|
84
|
+
readonly grammarInfo: GrammarInfo[];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export class Abbreviation extends Expression {
|
|
88
|
+
readonly acronym: boolean;
|
|
89
|
+
readonly initialism: boolean;
|
|
90
|
+
readonly truncation: boolean;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class Symbol extends Designation {}
|
|
94
|
+
|
|
95
|
+
export class LetterSymbol extends Symbol {
|
|
96
|
+
readonly text: string | null;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export class GraphicalSymbol extends Symbol {
|
|
100
|
+
readonly text: string | null;
|
|
101
|
+
readonly image: string | null;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export const GRAMMAR_GENDERS: readonly string[];
|
|
105
|
+
export const GRAMMAR_NUMBERS: readonly string[];
|
|
106
|
+
export const GRAMMAR_PARTS_OF_SPEECH: readonly string[];
|
|
107
|
+
|
|
108
|
+
export class GrammarInfo extends GlossaristModel {
|
|
52
109
|
readonly gender: string | null;
|
|
53
|
-
readonly
|
|
110
|
+
readonly number: string | null;
|
|
54
111
|
readonly partOfSpeech: string | null;
|
|
55
|
-
readonly
|
|
112
|
+
readonly noun: boolean;
|
|
113
|
+
readonly verb: boolean;
|
|
114
|
+
readonly adj: boolean;
|
|
115
|
+
readonly adverb: boolean;
|
|
116
|
+
readonly preposition: boolean;
|
|
117
|
+
readonly participle: boolean;
|
|
56
118
|
}
|
|
57
119
|
|
|
58
|
-
export class
|
|
59
|
-
|
|
60
|
-
readonly
|
|
120
|
+
export class Pronunciation extends GlossaristModel {
|
|
121
|
+
readonly content: string | null;
|
|
122
|
+
readonly language: string | null;
|
|
123
|
+
readonly script: string | null;
|
|
124
|
+
readonly country: string | null;
|
|
125
|
+
readonly system: string | null;
|
|
61
126
|
}
|
|
62
|
-
|
|
63
|
-
|
|
127
|
+
|
|
128
|
+
export class Locality extends GlossaristModel {
|
|
129
|
+
readonly type: string | null;
|
|
130
|
+
readonly referenceFrom: string | null;
|
|
131
|
+
readonly referenceTo: string | null;
|
|
64
132
|
}
|
|
65
133
|
|
|
66
134
|
export class Citation extends GlossaristModel {
|
|
67
|
-
readonly
|
|
68
|
-
readonly
|
|
69
|
-
readonly id: string | null;
|
|
70
|
-
readonly version: string | null;
|
|
71
|
-
readonly clause: string | null;
|
|
135
|
+
readonly ref: Citation.Ref | null;
|
|
136
|
+
readonly locality: Locality | null;
|
|
72
137
|
readonly link: string | null;
|
|
73
|
-
readonly
|
|
138
|
+
readonly original: string | null;
|
|
139
|
+
readonly customLocality: unknown;
|
|
140
|
+
toString(): string;
|
|
141
|
+
static fromJSON(data: Record<string, unknown>): Citation;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export namespace Citation {
|
|
145
|
+
class Ref extends GlossaristModel {
|
|
146
|
+
readonly source: string | null;
|
|
147
|
+
readonly id: string | null;
|
|
148
|
+
readonly version: string | null;
|
|
149
|
+
toString(): string;
|
|
150
|
+
static fromJSON(data: Record<string, unknown>): Ref;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export class ConceptRef extends GlossaristModel {
|
|
155
|
+
readonly source: string | null;
|
|
156
|
+
readonly id: string | null;
|
|
74
157
|
toString(): string;
|
|
158
|
+
static fromJSON(data: Record<string, unknown>): ConceptRef;
|
|
75
159
|
}
|
|
76
160
|
|
|
77
161
|
export class ConceptSource extends GlossaristModel {
|
|
@@ -85,7 +169,18 @@ export const RELATIONSHIP_TYPES: readonly string[];
|
|
|
85
169
|
export class RelatedConcept extends GlossaristModel {
|
|
86
170
|
readonly type: string;
|
|
87
171
|
readonly content: string | null;
|
|
88
|
-
readonly ref:
|
|
172
|
+
readonly ref: ConceptRef | null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export class ConceptReference extends GlossaristModel {
|
|
176
|
+
readonly conceptId: string | null;
|
|
177
|
+
readonly refType: string | null;
|
|
178
|
+
readonly source: string | null;
|
|
179
|
+
readonly urn: string | null;
|
|
180
|
+
readonly isLocal: boolean;
|
|
181
|
+
readonly isExternal: boolean;
|
|
182
|
+
static domain(conceptId: string): ConceptReference;
|
|
183
|
+
static fromJSON(data: Record<string, unknown>): ConceptReference;
|
|
89
184
|
}
|
|
90
185
|
|
|
91
186
|
export const DATE_TYPES: readonly string[];
|
|
@@ -97,14 +192,14 @@ export class ConceptDate extends GlossaristModel {
|
|
|
97
192
|
|
|
98
193
|
export class DetailedDefinition extends GlossaristModel {
|
|
99
194
|
readonly content: string;
|
|
100
|
-
readonly sources:
|
|
195
|
+
readonly sources: ConceptSource[];
|
|
101
196
|
}
|
|
102
197
|
|
|
103
198
|
export class NonVerbRep extends GlossaristModel {
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
106
|
-
readonly
|
|
107
|
-
readonly sources:
|
|
199
|
+
readonly type: string | null;
|
|
200
|
+
readonly ref: string | null;
|
|
201
|
+
readonly text: string | null;
|
|
202
|
+
readonly sources: ConceptSource[];
|
|
108
203
|
}
|
|
109
204
|
|
|
110
205
|
export class GcrStatistics extends GlossaristModel {
|
package/src/models/index.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
export { GlossaristModel } from './base.js';
|
|
2
2
|
export { Concept } from './concept.js';
|
|
3
3
|
export { LocalizedConcept } from './localized-concept.js';
|
|
4
|
-
export { Designation, Expression, Abbreviation, Symbol, GraphicalSymbol } from './designation.js';
|
|
4
|
+
export { Designation, Expression, Abbreviation, Symbol, LetterSymbol, GraphicalSymbol } from './designation.js';
|
|
5
5
|
export { Citation } from './citation.js';
|
|
6
|
+
export { ConceptRef } from './concept-ref.js';
|
|
6
7
|
export { ConceptSource } from './concept-source.js';
|
|
7
8
|
export { RelatedConcept, RELATIONSHIP_TYPES } from './related-concept.js';
|
|
9
|
+
export { ConceptReference } from './concept-reference.js';
|
|
8
10
|
export { ConceptDate, DATE_TYPES } from './concept-date.js';
|
|
9
11
|
export { DetailedDefinition } from './detailed-definition.js';
|
|
10
12
|
export { NonVerbRep } from './non-verb-rep.js';
|
|
13
|
+
export { Pronunciation } from './pronunciation.js';
|
|
14
|
+
export { GrammarInfo, GRAMMAR_GENDERS, GRAMMAR_NUMBERS, GRAMMAR_PARTS_OF_SPEECH } from './grammar-info.js';
|
|
15
|
+
export { Locality } from './locality.js';
|
|
11
16
|
export { GcrMetadata } from './gcr-metadata.js';
|
|
12
|
-
export { GcrStatistics } from './gcr-statistics.js'
|
|
17
|
+
export { GcrStatistics } from './gcr-statistics.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GlossaristModel } from './base.js';
|
|
2
|
+
|
|
3
|
+
export class Locality extends GlossaristModel {
|
|
4
|
+
constructor(data = {}) {
|
|
5
|
+
super();
|
|
6
|
+
this.type = data.type ?? null;
|
|
7
|
+
this.referenceFrom = data.reference_from ?? data.referenceFrom ?? null;
|
|
8
|
+
this.referenceTo = data.reference_to ?? data.referenceTo ?? null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
toJSON() {
|
|
12
|
+
const obj = {};
|
|
13
|
+
if (this.type != null) obj.type = this.type;
|
|
14
|
+
if (this.referenceFrom != null) obj.reference_from = this.referenceFrom;
|
|
15
|
+
if (this.referenceTo != null) obj.reference_to = this.referenceTo;
|
|
16
|
+
return obj;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
static fromJSON(data) {
|
|
20
|
+
return new Locality(data);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -2,23 +2,47 @@ import { GlossaristModel } from './base.js';
|
|
|
2
2
|
import { Designation } from './designation.js';
|
|
3
3
|
import { DetailedDefinition } from './detailed-definition.js';
|
|
4
4
|
import { ConceptSource } from './concept-source.js';
|
|
5
|
+
import { ConceptDate } from './concept-date.js';
|
|
6
|
+
import { NonVerbRep } from './non-verb-rep.js';
|
|
7
|
+
import { RelatedConcept } from './related-concept.js';
|
|
5
8
|
|
|
6
9
|
export class LocalizedConcept extends GlossaristModel {
|
|
7
10
|
constructor(data = {}) {
|
|
8
11
|
super();
|
|
9
12
|
this.languageCode = data.language_code ?? data.languageCode ?? null;
|
|
13
|
+
this.script = data.script ?? null;
|
|
14
|
+
this.system = data.system ?? null;
|
|
15
|
+
this.entryStatus = data.entry_status ?? data.entryStatus ?? null;
|
|
16
|
+
this.classification = data.classification ?? null;
|
|
17
|
+
this.reviewType = data.review_type ?? data.reviewType ?? null;
|
|
18
|
+
this.domain = data.domain ?? null;
|
|
19
|
+
this.release = data.release ?? null;
|
|
20
|
+
this.lineageSourceSimilarity = data.lineage_source_similarity ?? data.lineageSourceSimilarity ?? null;
|
|
21
|
+
|
|
22
|
+
this.reviewDate = data.review_date ?? data.reviewDate ?? null;
|
|
23
|
+
this.reviewDecisionDate = data.review_decision_date ?? data.reviewDecisionDate ?? null;
|
|
24
|
+
this.reviewDecisionEvent = data.review_decision_event ?? data.reviewDecisionEvent ?? null;
|
|
25
|
+
this.reviewStatus = data.review_status ?? data.reviewStatus ?? null;
|
|
26
|
+
this.reviewDecision = data.review_decision ?? data.reviewDecision ?? null;
|
|
27
|
+
this.reviewDecisionNotes = data.review_decision_notes ?? data.reviewDecisionNotes ?? null;
|
|
28
|
+
|
|
10
29
|
this._rawTerms = data.terms ?? [];
|
|
11
30
|
this._rawDefinition = data.definition ?? [];
|
|
12
31
|
this._rawSources = data.sources ?? [];
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
32
|
+
this._rawNotes = data.notes ?? [];
|
|
33
|
+
this._rawExamples = data.examples ?? [];
|
|
34
|
+
this._rawDates = data.dates ?? [];
|
|
35
|
+
this._rawNonVerbal = data.non_verbal_rep ?? data.non_verb ?? [];
|
|
36
|
+
this._rawRelated = data.related ?? [];
|
|
18
37
|
|
|
19
38
|
this._terms = null;
|
|
20
39
|
this._definitions = null;
|
|
21
40
|
this._sources = null;
|
|
41
|
+
this._notes = null;
|
|
42
|
+
this._examples = null;
|
|
43
|
+
this._dates = null;
|
|
44
|
+
this._nonVerbal = null;
|
|
45
|
+
this._related = null;
|
|
22
46
|
}
|
|
23
47
|
|
|
24
48
|
get terms() {
|
|
@@ -50,6 +74,51 @@ export class LocalizedConcept extends GlossaristModel {
|
|
|
50
74
|
return this._sources;
|
|
51
75
|
}
|
|
52
76
|
|
|
77
|
+
get notes() {
|
|
78
|
+
if (this._notes === null) {
|
|
79
|
+
this._notes = this._rawNotes.map(
|
|
80
|
+
n => n instanceof DetailedDefinition ? n : new DetailedDefinition(n)
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return this._notes;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get examples() {
|
|
87
|
+
if (this._examples === null) {
|
|
88
|
+
this._examples = this._rawExamples.map(
|
|
89
|
+
e => e instanceof DetailedDefinition ? e : new DetailedDefinition(e)
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
return this._examples;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
get dates() {
|
|
96
|
+
if (this._dates === null) {
|
|
97
|
+
this._dates = this._rawDates.map(
|
|
98
|
+
d => d instanceof ConceptDate ? d : new ConceptDate(d)
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return this._dates;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get nonVerbalRep() {
|
|
105
|
+
if (this._nonVerbal === null) {
|
|
106
|
+
this._nonVerbal = this._rawNonVerbal.map(
|
|
107
|
+
n => n instanceof NonVerbRep ? n : new NonVerbRep(n)
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
return this._nonVerbal;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
get related() {
|
|
114
|
+
if (this._related === null) {
|
|
115
|
+
this._related = this._rawRelated.map(
|
|
116
|
+
r => r instanceof RelatedConcept ? r : new RelatedConcept(r)
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return this._related;
|
|
120
|
+
}
|
|
121
|
+
|
|
53
122
|
get primaryDesignation() {
|
|
54
123
|
return this.terms[0]?.designation ?? null;
|
|
55
124
|
}
|
|
@@ -61,6 +130,21 @@ export class LocalizedConcept extends GlossaristModel {
|
|
|
61
130
|
toJSON() {
|
|
62
131
|
const obj = {};
|
|
63
132
|
if (this.languageCode) obj.language_code = this.languageCode;
|
|
133
|
+
if (this.script) obj.script = this.script;
|
|
134
|
+
if (this.system) obj.system = this.system;
|
|
135
|
+
if (this.entryStatus) obj.entry_status = this.entryStatus;
|
|
136
|
+
if (this.classification) obj.classification = this.classification;
|
|
137
|
+
if (this.reviewType) obj.review_type = this.reviewType;
|
|
138
|
+
if (this.domain) obj.domain = this.domain;
|
|
139
|
+
if (this.release) obj.release = this.release;
|
|
140
|
+
if (this.lineageSourceSimilarity != null) obj.lineage_source_similarity = this.lineageSourceSimilarity;
|
|
141
|
+
|
|
142
|
+
if (this.reviewDate) obj.review_date = this.reviewDate;
|
|
143
|
+
if (this.reviewDecisionDate) obj.review_decision_date = this.reviewDecisionDate;
|
|
144
|
+
if (this.reviewDecisionEvent) obj.review_decision_event = this.reviewDecisionEvent;
|
|
145
|
+
if (this.reviewStatus) obj.review_status = this.reviewStatus;
|
|
146
|
+
if (this.reviewDecision) obj.review_decision = this.reviewDecision;
|
|
147
|
+
if (this.reviewDecisionNotes) obj.review_decision_notes = this.reviewDecisionNotes;
|
|
64
148
|
|
|
65
149
|
const terms = this._terms ?? this._rawTerms;
|
|
66
150
|
if (terms.length > 0) {
|
|
@@ -72,17 +156,36 @@ export class LocalizedConcept extends GlossaristModel {
|
|
|
72
156
|
obj.definition = defs.map(d => (typeof d.toJSON === 'function') ? d.toJSON() : d);
|
|
73
157
|
}
|
|
74
158
|
|
|
75
|
-
|
|
76
|
-
if (
|
|
159
|
+
const notes = this._notes ?? (this._rawNotes.length > 0 ? this._rawNotes : []);
|
|
160
|
+
if (notes.length > 0) {
|
|
161
|
+
obj.notes = notes.map(n => (typeof n.toJSON === 'function') ? n.toJSON() : n);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const examples = this._examples ?? (this._rawExamples.length > 0 ? this._rawExamples : []);
|
|
165
|
+
if (examples.length > 0) {
|
|
166
|
+
obj.examples = examples.map(e => (typeof e.toJSON === 'function') ? e.toJSON() : e);
|
|
167
|
+
}
|
|
77
168
|
|
|
78
169
|
const sources = this._sources ?? (this._rawSources.length > 0 ? this._rawSources : []);
|
|
79
170
|
if (sources.length > 0) {
|
|
80
171
|
obj.sources = sources.map(s => (typeof s.toJSON === 'function') ? s.toJSON() : s);
|
|
81
172
|
}
|
|
82
173
|
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
|
|
174
|
+
const dates = this._dates ?? (this._rawDates.length > 0 ? this._rawDates : []);
|
|
175
|
+
if (dates.length > 0) {
|
|
176
|
+
obj.dates = dates.map(d => (typeof d.toJSON === 'function') ? d.toJSON() : d);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const nonVerbal = this._nonVerbal ?? (this._rawNonVerbal.length > 0 ? this._rawNonVerbal : []);
|
|
180
|
+
if (nonVerbal.length > 0) {
|
|
181
|
+
obj.non_verbal_rep = nonVerbal.map(n => (typeof n.toJSON === 'function') ? n.toJSON() : n);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const related = this._related ?? (this._rawRelated.length > 0 ? this._rawRelated : []);
|
|
185
|
+
if (related.length > 0) {
|
|
186
|
+
obj.related = related.map(r => (typeof r.toJSON === 'function') ? r.toJSON() : r);
|
|
187
|
+
}
|
|
188
|
+
|
|
86
189
|
return obj;
|
|
87
190
|
}
|
|
88
191
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { GlossaristModel } from './base.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ConceptSource } from './concept-source.js';
|
|
3
3
|
|
|
4
4
|
export class NonVerbRep extends GlossaristModel {
|
|
5
5
|
constructor(data = {}) {
|
|
6
6
|
super();
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
7
|
+
this.type = data.type ?? null;
|
|
8
|
+
this.ref = data.ref ?? null;
|
|
9
|
+
this.text = data.text ?? null;
|
|
10
10
|
this.sources = (data.sources ?? []).map(
|
|
11
|
-
s => s instanceof
|
|
11
|
+
s => s instanceof ConceptSource ? s : new ConceptSource(s)
|
|
12
12
|
);
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
toJSON() {
|
|
16
16
|
const obj = {};
|
|
17
|
-
if (this.
|
|
18
|
-
if (this.
|
|
19
|
-
if (this.
|
|
17
|
+
if (this.type != null) obj.type = this.type;
|
|
18
|
+
if (this.ref != null) obj.ref = this.ref;
|
|
19
|
+
if (this.text != null) obj.text = this.text;
|
|
20
20
|
if (this.sources.length > 0) obj.sources = this.sources.map(s => s.toJSON());
|
|
21
21
|
return obj;
|
|
22
22
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { GlossaristModel } from './base.js';
|
|
2
|
+
|
|
3
|
+
export class Pronunciation extends GlossaristModel {
|
|
4
|
+
constructor(data = {}) {
|
|
5
|
+
super();
|
|
6
|
+
this.content = data.content ?? null;
|
|
7
|
+
this.language = data.language ?? null;
|
|
8
|
+
this.script = data.script ?? null;
|
|
9
|
+
this.system = data.system ?? null;
|
|
10
|
+
this.country = data.country ?? null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
toJSON() {
|
|
14
|
+
const obj = {};
|
|
15
|
+
if (this.content != null) obj.content = this.content;
|
|
16
|
+
if (this.language != null) obj.language = this.language;
|
|
17
|
+
if (this.script != null) obj.script = this.script;
|
|
18
|
+
if (this.system != null) obj.system = this.system;
|
|
19
|
+
if (this.country != null) obj.country = this.country;
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
static fromJSON(data) {
|
|
24
|
+
return new Pronunciation(data);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
import { GlossaristModel } from './base.js';
|
|
2
|
-
import {
|
|
2
|
+
import { ConceptRef } from './concept-ref.js';
|
|
3
3
|
|
|
4
4
|
export const RELATIONSHIP_TYPES = Object.freeze([
|
|
5
|
-
|
|
6
|
-
'
|
|
7
|
-
|
|
5
|
+
// Lifecycle (ISO 10241-1)
|
|
6
|
+
'deprecates', 'supersedes', 'superseded_by',
|
|
7
|
+
// Hierarchical (SKOS)
|
|
8
|
+
'broader', 'narrower',
|
|
9
|
+
// ISO 25964 generic
|
|
10
|
+
'broader_generic', 'narrower_generic',
|
|
11
|
+
// ISO 25964 partitive
|
|
12
|
+
'broader_partitive', 'narrower_partitive',
|
|
13
|
+
// ISO 25964 instantial
|
|
14
|
+
'broader_instantial', 'narrower_instantial',
|
|
15
|
+
// SKOS mapping
|
|
16
|
+
'equivalent', 'close_match', 'broad_match', 'narrow_match', 'related_match',
|
|
17
|
+
// Associative (ISO 10241-1 / ISO 25964)
|
|
18
|
+
'see', 'related_concept', 'related_concept_broader', 'related_concept_narrower',
|
|
19
|
+
// Comparative (ISO 10241-1)
|
|
20
|
+
'compare', 'contrast',
|
|
21
|
+
// Spatiotemporal (ISO 25964 / TBX)
|
|
22
|
+
'sequentially_related_concept', 'spatially_related_concept', 'temporally_related_concept',
|
|
23
|
+
// Lexical (ISO 12620 / TBX)
|
|
24
|
+
'homograph', 'false_friend',
|
|
25
|
+
// Designation-level
|
|
26
|
+
'abbreviated_form_for', 'short_form_for',
|
|
8
27
|
]);
|
|
9
28
|
|
|
10
29
|
export class RelatedConcept extends GlossaristModel {
|
|
11
30
|
constructor(data = {}) {
|
|
12
31
|
super();
|
|
13
|
-
this.type = data.type ?? '
|
|
32
|
+
this.type = data.type ?? 'see';
|
|
14
33
|
this.content = data.content ?? null;
|
|
15
34
|
this.ref = data.ref
|
|
16
|
-
? (data.ref instanceof
|
|
35
|
+
? (data.ref instanceof ConceptRef ? data.ref : new ConceptRef(data.ref))
|
|
17
36
|
: null;
|
|
18
37
|
}
|
|
19
38
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ConceptRef } from './models/concept-ref.js';
|
|
2
|
+
|
|
1
3
|
export class Reference {
|
|
2
4
|
constructor(type, target, relationship, source) {
|
|
3
5
|
this.type = type;
|
|
@@ -7,12 +9,20 @@ export class Reference {
|
|
|
7
9
|
}
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
function refTarget(rc) {
|
|
13
|
+
if (rc.content) return rc.content;
|
|
14
|
+
if (rc.ref instanceof ConceptRef) {
|
|
15
|
+
return rc.ref.id ?? rc.ref.source ?? '';
|
|
16
|
+
}
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
|
|
10
20
|
export class ReferenceResolver {
|
|
11
21
|
extractReferences(concept) {
|
|
12
22
|
const refs = [];
|
|
13
23
|
|
|
14
24
|
for (const rc of concept.relatedConcepts) {
|
|
15
|
-
const target = rc
|
|
25
|
+
const target = refTarget(rc);
|
|
16
26
|
if (target) {
|
|
17
27
|
refs.push(new Reference('concept', target, rc.type, 'relatedConcepts'));
|
|
18
28
|
}
|
package/src/validators/index.js
CHANGED
|
@@ -4,15 +4,40 @@ export { ValidationResult } from './validation-result.js';
|
|
|
4
4
|
export { ConceptValidator, LanguageCodeRule, DesignationTypeRule, EntryStatusRule } from './concept-validator.js';
|
|
5
5
|
export { RegisterValidator } from './register-validator.js';
|
|
6
6
|
export { GcrValidator } from './gcr-validator.js';
|
|
7
|
+
export {
|
|
8
|
+
RefShapeRule,
|
|
9
|
+
LocalityCompletenessRule,
|
|
10
|
+
LocalizationConsistencyRule,
|
|
11
|
+
SchemaVersionRule,
|
|
12
|
+
DomainRefRule,
|
|
13
|
+
UuidFormatRule,
|
|
14
|
+
SourceUrnFormatRule,
|
|
15
|
+
} from './v3-rules.js';
|
|
7
16
|
|
|
8
17
|
import { ConceptValidator, LanguageCodeRule, DesignationTypeRule, EntryStatusRule } from './concept-validator.js';
|
|
9
18
|
import { RegisterValidator } from './register-validator.js';
|
|
10
19
|
import { GcrValidator } from './gcr-validator.js';
|
|
20
|
+
import {
|
|
21
|
+
RefShapeRule,
|
|
22
|
+
LocalityCompletenessRule,
|
|
23
|
+
LocalizationConsistencyRule,
|
|
24
|
+
SchemaVersionRule,
|
|
25
|
+
DomainRefRule,
|
|
26
|
+
UuidFormatRule,
|
|
27
|
+
SourceUrnFormatRule,
|
|
28
|
+
} from './v3-rules.js';
|
|
11
29
|
|
|
12
30
|
const _default = new ConceptValidator()
|
|
13
31
|
.addRule(new LanguageCodeRule())
|
|
14
32
|
.addRule(new DesignationTypeRule())
|
|
15
|
-
.addRule(new EntryStatusRule())
|
|
33
|
+
.addRule(new EntryStatusRule())
|
|
34
|
+
.addRule(new RefShapeRule())
|
|
35
|
+
.addRule(new LocalityCompletenessRule())
|
|
36
|
+
.addRule(new LocalizationConsistencyRule())
|
|
37
|
+
.addRule(new SchemaVersionRule())
|
|
38
|
+
.addRule(new DomainRefRule())
|
|
39
|
+
.addRule(new UuidFormatRule())
|
|
40
|
+
.addRule(new SourceUrnFormatRule());
|
|
16
41
|
|
|
17
42
|
export function validateConcept(concept) {
|
|
18
43
|
return _default.validate(concept);
|