glossarist 2.14.14 → 2.14.16
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.
- checksums.yaml +4 -4
- data/README.adoc +6 -0
- data/docs/data-format.adoc +226 -0
- data/docs/rich-text.adoc +55 -0
- data/docs/usage.adoc +134 -0
- data/lib/glossarist/config.rb +14 -0
- data/lib/glossarist/managed_concept.rb +1 -1
- data/lib/glossarist/managed_concept_collection.rb +5 -0
- data/lib/glossarist/resolution_adapter/bibliography.rb +6 -1
- data/lib/glossarist/sts/importer.rb +9 -9
- data/lib/glossarist/validation/rules/default_language_rule.rb +36 -0
- data/lib/glossarist/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a584d4edbe83762292055fa2a0e6af624d66a277b511a28ad34e01f03e4c05fc
|
|
4
|
+
data.tar.gz: d5e638432a0d281469f4531b4ded63047b68b8005cbdaeade9d09a32c75172dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c1804db5d0ea4deaf8e87a35545570856a42d66593d8cf07e93bf43a1e81b464a13bd875590f022c6f548c0438a595f5b74d1e98ab394eed22f7d478cc229903
|
|
7
|
+
data.tar.gz: 6d5db078479e2824d7dfd82baa39a127e86f04bcfd1eee56be26000d6b5f372a23a31f0a39e5bdd66cdb765d241f5c80981d748fe7883cb093c0c11bcb6ddbc3
|
data/README.adoc
CHANGED
|
@@ -1949,6 +1949,12 @@ end
|
|
|
1949
1949
|
This gem is developed, maintained and funded by
|
|
1950
1950
|
https://www.ribose.com[Ribose Inc.]
|
|
1951
1951
|
|
|
1952
|
+
== Further documentation
|
|
1953
|
+
|
|
1954
|
+
* xref:docs/usage.adoc[Creating and managing concepts] — the in-memory API: `ManagedConcept`, localizations, designations, relations, persistence through `GlossaryStore`
|
|
1955
|
+
* xref:docs/data-format.adoc[Dataset format specification] — the V3 on-disk layout: concept documents, relations, bibliography, non-verbal entities, packaging
|
|
1956
|
+
* xref:docs/rich-text.adoc[Rich text] — what is allowed inside definition content: inline mentions, emphasis, stem expressions
|
|
1957
|
+
|
|
1952
1958
|
== License
|
|
1953
1959
|
|
|
1954
1960
|
The gem is available as open source under the terms of the
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
= Glossarist dataset format specification
|
|
2
|
+
|
|
3
|
+
This document specifies the V3 on-disk dataset format written and read by this gem (normative for what `GlossaryStore` accepts and emits). The concepts themselves are defined by the https://github.com/glossarist/concept-model[Glossarist concept model].
|
|
4
|
+
|
|
5
|
+
== Dataset directory layout
|
|
6
|
+
|
|
7
|
+
----
|
|
8
|
+
dataset/
|
|
9
|
+
├── metadata.yaml # dataset metadata (optional but recommended)
|
|
10
|
+
├── register.yaml # register definition (shortname, subregisters)
|
|
11
|
+
├── bibliography.yaml # dataset bibliography (single wrapper key)
|
|
12
|
+
├── concepts/
|
|
13
|
+
│ └── <uuid>.yaml # one concept document per file (multi-doc stream)
|
|
14
|
+
├── relations/ # V3 n-ary relations, optional
|
|
15
|
+
│ └── <comprehensive-id>/<slug>.yaml
|
|
16
|
+
├── figures/ # dataset-level non-verbal entities, optional
|
|
17
|
+
│ └── <id>.yaml
|
|
18
|
+
├── tables/
|
|
19
|
+
│ └── <id>.yaml
|
|
20
|
+
├── formulas/
|
|
21
|
+
│ └── <id>.yaml
|
|
22
|
+
└── images/ # binary assets referenced by figures
|
|
23
|
+
└── <ref>.png|jpg|...
|
|
24
|
+
----
|
|
25
|
+
|
|
26
|
+
Layout detection is model-driven: `GlossaryStore#load_directory` dispatches to the V1 legacy reader, the legacy managed layout, the grouped-at-root layout, or the package layout above, based on what the directory contains. New datasets use the package layout.
|
|
27
|
+
|
|
28
|
+
A dataset directory can be packaged as a `.gcr` (ZIP) file containing the same layout; `GlossaryStore#load_zip`/`save_zip` read and write it.
|
|
29
|
+
|
|
30
|
+
== metadata.yaml
|
|
31
|
+
|
|
32
|
+
A YAML mapping; the gem consumes:
|
|
33
|
+
|
|
34
|
+
[,yaml]
|
|
35
|
+
----
|
|
36
|
+
shortname: my-glossary
|
|
37
|
+
version: 1.0.0
|
|
38
|
+
schema_version: "3"
|
|
39
|
+
concept_count: 42
|
|
40
|
+
----
|
|
41
|
+
|
|
42
|
+
`schema_version` selects the document model (`"3"` → `V3::ConceptDocument`; anything else falls back by content). Unknown keys are preserved as metadata and round-tripped.
|
|
43
|
+
|
|
44
|
+
== register.yaml
|
|
45
|
+
|
|
46
|
+
A YAML mapping naming the register and its subregisters:
|
|
47
|
+
|
|
48
|
+
[,yaml]
|
|
49
|
+
----
|
|
50
|
+
shortname: my-glossary
|
|
51
|
+
subregisters:
|
|
52
|
+
eng:
|
|
53
|
+
----
|
|
54
|
+
|
|
55
|
+
Each subregister key is a language code; concepts belong to subregisters through their localizations.
|
|
56
|
+
|
|
57
|
+
== Concept documents (concepts/<uuid>.yaml)
|
|
58
|
+
|
|
59
|
+
A concept file is a **multi-document YAML stream**: document 0 is the concept, documents 1.. are its localizations. The filename stem is the concept's record `id` (a UUID, or a clause identifier for clause-keyed datasets such as `3.1.1.1.yaml`).
|
|
60
|
+
|
|
61
|
+
[,yaml]
|
|
62
|
+
----
|
|
63
|
+
---
|
|
64
|
+
id: 3a75582e-699c-4e08-b26a-3ebd6fb00102
|
|
65
|
+
data:
|
|
66
|
+
identifier: 102-01-01
|
|
67
|
+
localized_concepts:
|
|
68
|
+
eng: 4b0e2358-79ba-5581-a8b9-17a34a2e1dce
|
|
69
|
+
sources: []
|
|
70
|
+
---
|
|
71
|
+
data:
|
|
72
|
+
identifier: 102-01-01
|
|
73
|
+
language_code: eng
|
|
74
|
+
terms:
|
|
75
|
+
- type: expression
|
|
76
|
+
normative_status: preferred
|
|
77
|
+
designation: concept
|
|
78
|
+
definition:
|
|
79
|
+
- content: A unit of thought formalized in {{concept:my-glossary:other-concept}}.
|
|
80
|
+
notes: []
|
|
81
|
+
examples: []
|
|
82
|
+
sources: []
|
|
83
|
+
date_accepted: '2023-01-01T00:00:00+00:00'
|
|
84
|
+
id: 4b0e2358-79ba-5581-a8b9-17a34a2e1dce
|
|
85
|
+
----
|
|
86
|
+
|
|
87
|
+
Document 0 (`data:` payload):
|
|
88
|
+
|
|
89
|
+
[cols="1m,1,2"]
|
|
90
|
+
|===
|
|
91
|
+
|Field |Type |Meaning
|
|
92
|
+
|
|
93
|
+
|`id`
|
|
94
|
+
|string
|
|
95
|
+
|Record key; duplicated from the filename by the writer. Also seeds the concept `uuid` when the stream lacks one.
|
|
96
|
+
|
|
97
|
+
|`data.identifier`
|
|
98
|
+
|string
|
|
99
|
+
|Human-facing concept identifier (term number).
|
|
100
|
+
|
|
101
|
+
|`data.localized_concepts`
|
|
102
|
+
|map lang → uuid
|
|
103
|
+
|Links each language to its localization document.
|
|
104
|
+
|
|
105
|
+
|`data.sources`, `data.domains`, `data.tags`, `data.figures`, `data.tables`, `data.formulas`
|
|
106
|
+
|collections
|
|
107
|
+
|Concept-level metadata references.
|
|
108
|
+
|
|
109
|
+
|`related`
|
|
110
|
+
|array
|
|
111
|
+
|Concept-level `RelatedConcept`s (type + content). Lives at the concept level only in V3.
|
|
112
|
+
|===
|
|
113
|
+
|
|
114
|
+
Localization documents (`data:` payload = `ConceptData`):
|
|
115
|
+
|
|
116
|
+
[cols="1m,1,2"]
|
|
117
|
+
|===
|
|
118
|
+
|Field |Type |Meaning
|
|
119
|
+
|
|
120
|
+
|`language_code`
|
|
121
|
+
|string (ISO 639)
|
|
122
|
+
|Language of this localization.
|
|
123
|
+
|
|
124
|
+
|`terms`
|
|
125
|
+
|array of designations
|
|
126
|
+
|`type` (`expression`, `abbreviation`, `symbol`, `letter_symbol`, `graphical_symbol`), `normative_status` (`preferred`, `admitted`, `deprecated`, `superseded`), `designation`, plus designation-specific fields.
|
|
127
|
+
|
|
128
|
+
|`definition`
|
|
129
|
+
|array
|
|
130
|
+
|Each entry: `content` (rich text — see xref:rich-text.adoc[Rich text]), optional `sources`.
|
|
131
|
+
|
|
132
|
+
|`notes`, `examples`
|
|
133
|
+
|array
|
|
134
|
+
|Same shape as `definition` entries.
|
|
135
|
+
|
|
136
|
+
|`sources`
|
|
137
|
+
|array
|
|
138
|
+
|`origin` (citation) + `type` (`authoritative`, `clause`, ...).
|
|
139
|
+
|
|
140
|
+
|`dates`
|
|
141
|
+
|array
|
|
142
|
+
|`type` (`accepted`, `amended`, ...) + `date` (ISO 8601).
|
|
143
|
+
|
|
144
|
+
|`entry_status`, `review_type`, `classification`
|
|
145
|
+
|string
|
|
146
|
+
|Localization lifecycle fields.
|
|
147
|
+
|===
|
|
148
|
+
|
|
149
|
+
Both snake_case and camelCase keys are accepted on read; the writer emits snake_case.
|
|
150
|
+
|
|
151
|
+
== Relations (relations/)
|
|
152
|
+
|
|
153
|
+
One file per n-ary relation (hyperedge), named `<criterion-slug>.yaml` under the comprehensive concept's id. The `type` field distinguishes the relation kind (`partitive_relation`, `generic_relation`, ...):
|
|
154
|
+
|
|
155
|
+
[,yaml]
|
|
156
|
+
----
|
|
157
|
+
---
|
|
158
|
+
type: partitive_relation
|
|
159
|
+
comprehensive:
|
|
160
|
+
source: VIM
|
|
161
|
+
id: '112-02-09'
|
|
162
|
+
members:
|
|
163
|
+
- ref:
|
|
164
|
+
source: VIM
|
|
165
|
+
id: '112-02-10'
|
|
166
|
+
presence: required # or optional (ISO 704 line style)
|
|
167
|
+
count: exactly_one # or at_least_one / multiple
|
|
168
|
+
is_delimiting: false
|
|
169
|
+
- ref:
|
|
170
|
+
source: VIM
|
|
171
|
+
id: '112-03-26'
|
|
172
|
+
completeness: complete # or partial
|
|
173
|
+
criterion:
|
|
174
|
+
eng: measurement result composition
|
|
175
|
+
----
|
|
176
|
+
|
|
177
|
+
ISO 704 requires at least two members per relation; `Validation::Rules` enforces structural invariants (GLS-2xx series).
|
|
178
|
+
|
|
179
|
+
A single comprehensive concept can carry N hyperedges (one per criterion of subdivision), each in its own file under `relations/<comprehensive-id>/`. Legacy files with a `partitives:` key (member list with the `multiplicity` enum instead of the `presence`/`count` decomposition) are read for backward compatibility; the writer emits the `members` form above.
|
|
180
|
+
|
|
181
|
+
[NOTE]
|
|
182
|
+
--
|
|
183
|
+
*Remaining transition step.* The concept-model shapes' property path still reads `hasPartitiveRelation`; the v3.3 shape bump renames it to `hasMember` (the native ontology property). The wire keys and semantics shown here are current.
|
|
184
|
+
--
|
|
185
|
+
|
|
186
|
+
== bibliography.yaml
|
|
187
|
+
|
|
188
|
+
The V3 wrapper-key form — a single mapping whose one key wraps an ordered array of typed entries:
|
|
189
|
+
|
|
190
|
+
[,yaml]
|
|
191
|
+
----
|
|
192
|
+
bibliography:
|
|
193
|
+
- id: iso-10241-1
|
|
194
|
+
type: citation
|
|
195
|
+
citation:
|
|
196
|
+
ref: ISO 10241-1
|
|
197
|
+
type: international-standard
|
|
198
|
+
bibdata:
|
|
199
|
+
...relaton bibliography item...
|
|
200
|
+
----
|
|
201
|
+
|
|
202
|
+
`bibdata` carries a Relaton bibliography item; the wrapper form is glossarist's own wire shape and is not Relaton's format.
|
|
203
|
+
|
|
204
|
+
== Non-verbal entities (figures/, tables/, formulas/)
|
|
205
|
+
|
|
206
|
+
One typed document per file, referenced from concept data via `FigureReference`/`TableReference`/`FormulaReference`:
|
|
207
|
+
|
|
208
|
+
[,yaml]
|
|
209
|
+
----
|
|
210
|
+
id: fig-1
|
|
211
|
+
image: images/fig-1.png
|
|
212
|
+
label: Figure 1
|
|
213
|
+
----
|
|
214
|
+
|
|
215
|
+
== Default language
|
|
216
|
+
|
|
217
|
+
The dataset's primary language defaults to `"eng"`. It is customizable:
|
|
218
|
+
|
|
219
|
+
* per dataset: `default_language: <ISO 639>` in `glossarist.yaml` in the working directory, or
|
|
220
|
+
* programmatically: `Glossarist.config.default_language = "deu"`.
|
|
221
|
+
|
|
222
|
+
`ManagedConcept#default_lang` returns the default-language localization, and validation rule GLS-311 requires a concept with localizations to carry one in that language.
|
|
223
|
+
|
|
224
|
+
== Packaging (.gcr)
|
|
225
|
+
|
|
226
|
+
`glossarist package <dataset>` produces a ZIP with `metadata.yaml`, `register.yaml`, `concepts/*.yaml` (plus the optional directories) and compiled export formats on request (`--compiled-formats tbx,jsonld,turtle,jsonl`). `glossarist validate` checks a dataset or `.gcr` against the validation rules; `glossarist upgrade` migrates V0/V1/V2 datasets to the current layout.
|
data/docs/rich-text.adoc
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
= Rich text in concept content
|
|
2
|
+
|
|
3
|
+
This document specifies what is allowed inside free-text content fields — `definition`/`notes`/`examples` `content`, designation `prefix`/`usage_info`/`field_of_application`, and related-concept `content` strings — and how they are parsed.
|
|
4
|
+
|
|
5
|
+
== Content is a string
|
|
6
|
+
|
|
7
|
+
Content fields are plain YAML scalars. Markup inside them is convention-based; the gem parses mentions (`{{...}}`) structurally and leaves everything else to renderers.
|
|
8
|
+
|
|
9
|
+
== Inline mentions
|
|
10
|
+
|
|
11
|
+
`{{...}}` delimits an inline mention. The grammar (enforced by `Glossarist::Mentions::Parser`):
|
|
12
|
+
|
|
13
|
+
----
|
|
14
|
+
{{ kind : target [ , label ] }}
|
|
15
|
+
----
|
|
16
|
+
|
|
17
|
+
* **kind** — one of: `concept`, `cite`, `fig`, `table`, `formula`, `bib`, `link`, `image`. Unknown kinds raise `Mentions::InvalidMentionError`.
|
|
18
|
+
* **target** — kind-specific reference. For `concept`/`cite`/`bib`: `DATASET:ID` (optionally nested URN segments); for `link`: a URL; for `fig`/`table`/`formula`/`image`: a dataset-internal reference or path.
|
|
19
|
+
* **label** — optional display text after the first comma (e.g. `{{cite:my-glossary:iso-10241,ISO 10241-1}}`).
|
|
20
|
+
|
|
21
|
+
Mentions may appear anywhere in content. A mention token **must not be broken across lines by serialization**: glossarist's writer emits content without folding inside tokens (pinned by `spec/unit/mention_serialization_spec.rb`, glossarist#275).
|
|
22
|
+
|
|
23
|
+
[,ruby]
|
|
24
|
+
----
|
|
25
|
+
Glossarist.parse_mentions("See {{concept:my-glossary:other-concept,other}}.")
|
|
26
|
+
# => [{ kind: "concept", target: {dataset: "my-glossary", id: "other-concept"},
|
|
27
|
+
# label: "other", raw: "{{concept:...}}", start: 4, end: ... }, ...]
|
|
28
|
+
----
|
|
29
|
+
|
|
30
|
+
Text outside mentions is passed through verbatim; the parser returns `kind: "text"` segments for it.
|
|
31
|
+
|
|
32
|
+
== Lightweight emphasis
|
|
33
|
+
|
|
34
|
+
By convention, content carries GitHub-flavored *emphasis* markers that renderers honor:
|
|
35
|
+
|
|
36
|
+
* `**bold**`
|
|
37
|
+
* `*italic*`
|
|
38
|
+
* `` `code` ``
|
|
39
|
+
|
|
40
|
+
The gem itself does not parse these — they survive round-trips verbatim, and renderers (metanorma vocabulary rendering, concept-browser) convert them.
|
|
41
|
+
|
|
42
|
+
== Stem expressions
|
|
43
|
+
|
|
44
|
+
Mathematical content uses AsciiMath/LaTeX stem notation, `stem:[...]`, where the bracketed expression is rendered by the consumer's math engine (Plurimath family). Formulas referenced rather than inlined live in `formulas/` as dataset-level entities (see xref:data-format.adoc[the dataset format specification]).
|
|
45
|
+
|
|
46
|
+
== What is not allowed
|
|
47
|
+
|
|
48
|
+
* **Unbalanced mention delimiters** — a stray `{{` without `}}` is left as literal text by the parser but is reserved syntax; do not author it.
|
|
49
|
+
* **Multi-line mentions** — a token must live on one line.
|
|
50
|
+
* **HTML/XML markup** — not parsed, not rendered; use the emphasis conventions above.
|
|
51
|
+
* **YAML anchors/aliases inside content** — aliases resolve on parse but make files dependent on emitter anchor naming; write content literally.
|
|
52
|
+
|
|
53
|
+
== Round-trip contract
|
|
54
|
+
|
|
55
|
+
Load → serialize preserves content byte-for-byte except for YAML scalar normalization (quoting style, line-wrapping outside tokens). Mention tokens, emphasis markers and stem expressions are never altered by the gem's writer.
|
data/docs/usage.adoc
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
= Creating and managing concepts programmatically
|
|
2
|
+
|
|
3
|
+
This guide shows the in-memory API: building `ManagedConcept` objects, attaching localizations, and persisting them through `GlossaryStore`. For the on-disk format see xref:data-format.adoc[the dataset format specification]; for what may appear inside definition text see xref:rich-text.adoc[the rich-text specification].
|
|
4
|
+
|
|
5
|
+
== Building a concept
|
|
6
|
+
|
|
7
|
+
A `ManagedConcept` is the unit of a dataset. Its identity is the `uuid`; its language-independent metadata lives in `data` (`ManagedConceptData`); all language-dependent content lives in *localizations* (`LocalizedConcept`, keyed by ISO 639 code).
|
|
8
|
+
|
|
9
|
+
[,ruby]
|
|
10
|
+
----
|
|
11
|
+
require "glossarist"
|
|
12
|
+
|
|
13
|
+
concept = Glossarist::ManagedConcept.new(
|
|
14
|
+
data: Glossarist::ManagedConceptData.new(id: "102-01-01"),
|
|
15
|
+
)
|
|
16
|
+
concept.uuid = "3a75582e-699c-4e08-b26a-3ebd6fb00102"
|
|
17
|
+
----
|
|
18
|
+
|
|
19
|
+
== Adding a localization
|
|
20
|
+
|
|
21
|
+
Each localization carries a `ConceptData` payload: designations, definitions, notes, examples, sources and dates.
|
|
22
|
+
|
|
23
|
+
[,ruby]
|
|
24
|
+
----
|
|
25
|
+
l10n = Glossarist::LocalizedConcept.new(
|
|
26
|
+
language_code: "eng",
|
|
27
|
+
data: Glossarist::ConceptData.new(language_code: "eng"),
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
l10n.data.terms = [
|
|
31
|
+
Glossarist::Designation::Expression.new(
|
|
32
|
+
designation: "concept",
|
|
33
|
+
normative_status: "preferred",
|
|
34
|
+
),
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
l10n.data.definition = [
|
|
38
|
+
Glossarist::DetailedDefinition.new(
|
|
39
|
+
content: "A {{concept:my-glossary:other-concept}} unit of thought.",
|
|
40
|
+
),
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
l10n.data.examples = [
|
|
44
|
+
Glossarist::DetailedDefinition.new(content: "An example sentence."),
|
|
45
|
+
]
|
|
46
|
+
l10n.data.notes = [
|
|
47
|
+
Glossarist::DetailedDefinition.new(
|
|
48
|
+
content: "A note with a citation to {{cite:my-glossary:source-1,ISO 10241-1}}.",
|
|
49
|
+
),
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
concept.add_localization(l10n)
|
|
53
|
+
----
|
|
54
|
+
|
|
55
|
+
`add_localization` stores one localization per language code; adding the same language twice replaces the first.
|
|
56
|
+
|
|
57
|
+
The concept's *default language* localization is available through `concept.default_lang`. The default language is `"eng"` unless customized (see xref:data-format.adoc#default-language[Default language]).
|
|
58
|
+
|
|
59
|
+
== Designations
|
|
60
|
+
|
|
61
|
+
Designations are typed; use the subclass matching the designation kind:
|
|
62
|
+
|
|
63
|
+
|===
|
|
64
|
+
| Kind | Class | Extra fields
|
|
65
|
+
|
|
66
|
+
| term / expression
|
|
67
|
+
| `Designation::Expression`
|
|
68
|
+
| `prefix`, `usage_info`, `field_of_application`, `grammar_info`
|
|
69
|
+
|
|
70
|
+
| abbreviation
|
|
71
|
+
| `Designation::Abbreviation` (subclass of Expression)
|
|
72
|
+
| `acronym`, `initialism`, `truncation`
|
|
73
|
+
|
|
74
|
+
| symbol
|
|
75
|
+
| `Designation::Symbol`
|
|
76
|
+
| —
|
|
77
|
+
|
|
78
|
+
| letter symbol
|
|
79
|
+
| `Designation::LetterSymbol`
|
|
80
|
+
| `text`
|
|
81
|
+
|
|
82
|
+
| graphical symbol
|
|
83
|
+
| `Designation::GraphicalSymbol`
|
|
84
|
+
| `text`, `image`
|
|
85
|
+
|===
|
|
86
|
+
|
|
87
|
+
All designations carry `normative_status` (`preferred`, `admitted`, `deprecated`, `superseded`) and may carry `sources`, `pronunciation`, `related` (designation-level relations such as `abbreviated_form_for`).
|
|
88
|
+
|
|
89
|
+
== Relations
|
|
90
|
+
|
|
91
|
+
Concept-level relationships are `RelatedConcept` objects on `concept.related`:
|
|
92
|
+
|
|
93
|
+
[,ruby]
|
|
94
|
+
----
|
|
95
|
+
concept.related = [
|
|
96
|
+
Glossarist::RelatedConcept.new(
|
|
97
|
+
type: "broader",
|
|
98
|
+
content: { "eng" => "parent concept" },
|
|
99
|
+
),
|
|
100
|
+
]
|
|
101
|
+
----
|
|
102
|
+
|
|
103
|
+
The full relation-type vocabulary (ISO 10241-1, ISO 25964/SKOS, ISO 12620/TBX and designation-level types) is listed in `config.yml` under `related_concept.type`. N-ary partitive relations (`PartitiveRelation`) are covered in xref:data-format.adoc#partitive-relations[the dataset format specification].
|
|
104
|
+
|
|
105
|
+
== Persisting
|
|
106
|
+
|
|
107
|
+
`GlossaryStore` is the dataset abstraction — loading, saving, CRUD, validation and packaging all go through it.
|
|
108
|
+
|
|
109
|
+
[,ruby]
|
|
110
|
+
----
|
|
111
|
+
store = Glossarist::GlossaryStore.new
|
|
112
|
+
store.load_directory("path/to/dataset") # or load_zip("dataset.gcr")
|
|
113
|
+
|
|
114
|
+
store.concepts # all ManagedConcepts
|
|
115
|
+
store.concept("3a75582e-...") # fetch by uuid
|
|
116
|
+
store.concept_exists?("3a75582e-...")
|
|
117
|
+
store.add_concept(concept)
|
|
118
|
+
store.remove_concept("3a75582e-...")
|
|
119
|
+
|
|
120
|
+
store.save_directory("path/to/dataset") # write back
|
|
121
|
+
store.save_zip("dataset.gcr") # .gcr package
|
|
122
|
+
----
|
|
123
|
+
|
|
124
|
+
== Validating
|
|
125
|
+
|
|
126
|
+
[,ruby]
|
|
127
|
+
----
|
|
128
|
+
result = Glossarist::DatasetValidator.new.validate("path/to/dataset")
|
|
129
|
+
result.valid? # => true/false
|
|
130
|
+
result.errors # array of messages
|
|
131
|
+
result.warnings
|
|
132
|
+
----
|
|
133
|
+
|
|
134
|
+
Validation rules are auto-registered from `lib/glossarist/validation/rules/`; the default-language presence check (GLS-311) uses the dataset's default language (xref:data-format.adoc#default-language[Default language]).
|
data/lib/glossarist/config.rb
CHANGED
|
@@ -22,8 +22,14 @@ module Glossarist
|
|
|
22
22
|
|
|
23
23
|
@registered_classes = DEFAULT_CLASSES.dup
|
|
24
24
|
@extension_attributes = @config["extension_attributes"] || []
|
|
25
|
+
@default_language = @config["default_language"] || "eng"
|
|
25
26
|
end
|
|
26
27
|
|
|
28
|
+
# ISO 639 code of the dataset's primary language. Used by
|
|
29
|
+
# ManagedConcept#default_lang and the default-language validation
|
|
30
|
+
# rule; customizable via glossarist.yaml (`default_language:`).
|
|
31
|
+
attr_accessor :default_language
|
|
32
|
+
|
|
27
33
|
def class_for(name)
|
|
28
34
|
@registered_classes[name.to_sym]
|
|
29
35
|
end
|
|
@@ -45,6 +51,14 @@ module Glossarist
|
|
|
45
51
|
instance.class_for(name)
|
|
46
52
|
end
|
|
47
53
|
|
|
54
|
+
def default_language
|
|
55
|
+
instance.default_language
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def default_language=(lang)
|
|
59
|
+
instance.default_language = lang
|
|
60
|
+
end
|
|
61
|
+
|
|
48
62
|
def extension_attributes
|
|
49
63
|
instance.extension_attributes
|
|
50
64
|
end
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Glossarist
|
|
4
|
+
# Deprecated: retained for ABI compatibility only. No internal callers
|
|
5
|
+
# remain — build concepts as a plain Array and persist through
|
|
6
|
+
# GlossaryStore. Removal is slated for the next major release.
|
|
4
7
|
class ManagedConceptCollection
|
|
5
8
|
include Enumerable
|
|
6
9
|
|
|
7
10
|
attr_accessor :managed_concepts
|
|
8
11
|
|
|
9
12
|
def initialize(file_key: nil)
|
|
13
|
+
warn "[glossarist] ManagedConceptCollection is deprecated; use a " \
|
|
14
|
+
"plain Array and GlossaryStore (removal slated for 3.0)"
|
|
10
15
|
@managed_concepts = []
|
|
11
16
|
@managed_concepts_ids = {}
|
|
12
17
|
@file_key = file_key
|
|
@@ -15,7 +15,12 @@ module Glossarist
|
|
|
15
15
|
return nil unless reference.is_a?(ConceptReference)
|
|
16
16
|
return nil unless reference.source == @source_id
|
|
17
17
|
|
|
18
|
-
concepts
|
|
18
|
+
# concepts is any Enumerable of ManagedConcepts (Array or
|
|
19
|
+
# GlossaryStore); match the uuid or the data id, with version.
|
|
20
|
+
concepts.find do |c|
|
|
21
|
+
(c.uuid == reference.concept_id || c.data&.id == reference.concept_id) &&
|
|
22
|
+
(reference.version.nil? || c.version == reference.version)
|
|
23
|
+
end
|
|
19
24
|
end
|
|
20
25
|
end
|
|
21
26
|
end
|
|
@@ -58,7 +58,7 @@ module Glossarist
|
|
|
58
58
|
save_to_path(existing, dataset_path)
|
|
59
59
|
|
|
60
60
|
ImportResult.new(
|
|
61
|
-
concepts: existing
|
|
61
|
+
concepts: existing,
|
|
62
62
|
conflicts: result_state.conflicts,
|
|
63
63
|
source_files: xml_files,
|
|
64
64
|
skipped_count: result_state.skipped,
|
|
@@ -78,7 +78,7 @@ module Glossarist
|
|
|
78
78
|
existing_mc = index[key]
|
|
79
79
|
|
|
80
80
|
if existing_mc.nil?
|
|
81
|
-
existing
|
|
81
|
+
existing << mc
|
|
82
82
|
index[key] = mc
|
|
83
83
|
else
|
|
84
84
|
state.conflicts << DuplicateConflict.new(
|
|
@@ -179,26 +179,26 @@ module Glossarist
|
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
def replace_in_collection(collection, old_mc, new_mc)
|
|
182
|
-
collection.
|
|
183
|
-
collection
|
|
182
|
+
collection.delete(old_mc)
|
|
183
|
+
collection << new_mc
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
def load_existing(path)
|
|
187
|
-
collection =
|
|
187
|
+
collection = []
|
|
188
188
|
if path.end_with?(".gcr")
|
|
189
189
|
package = GcrPackage.load(path)
|
|
190
|
-
package.concepts.each { |mc| collection
|
|
190
|
+
package.concepts.each { |mc| collection << mc }
|
|
191
191
|
else
|
|
192
192
|
GlossaryStore.new.tap do |s|
|
|
193
193
|
s.load(path)
|
|
194
|
-
end.each_concept { |mc| collection
|
|
194
|
+
end.each_concept { |mc| collection << mc }
|
|
195
195
|
end
|
|
196
196
|
collection
|
|
197
197
|
end
|
|
198
198
|
|
|
199
199
|
def save_to_path(collection, path)
|
|
200
200
|
if path.end_with?(".gcr")
|
|
201
|
-
tmpdir = build_temp_dataset(collection
|
|
201
|
+
tmpdir = build_temp_dataset(collection)
|
|
202
202
|
begin
|
|
203
203
|
GC.start
|
|
204
204
|
tmp_gcr = "#{path}.tmp.#{Process.pid}"
|
|
@@ -215,7 +215,7 @@ module Glossarist
|
|
|
215
215
|
FileUtils.rm_f(tmp_gcr)
|
|
216
216
|
end
|
|
217
217
|
else
|
|
218
|
-
save_dataset(collection
|
|
218
|
+
save_dataset(collection, path)
|
|
219
219
|
end
|
|
220
220
|
end
|
|
221
221
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Glossarist
|
|
4
|
+
module Validation
|
|
5
|
+
module Rules
|
|
6
|
+
# glossarist#6: a concept with localizations must carry one in the
|
|
7
|
+
# dataset's default language (Config.default_language, "eng" unless
|
|
8
|
+
# customized). Concepts with no localizations at all are not this
|
|
9
|
+
# rule's concern.
|
|
10
|
+
class DefaultLanguageRule < Base
|
|
11
|
+
def code = "GLS-311"
|
|
12
|
+
def category = :content
|
|
13
|
+
def severity = "error"
|
|
14
|
+
def scope = :concept
|
|
15
|
+
|
|
16
|
+
def check(context)
|
|
17
|
+
concept = context.concept
|
|
18
|
+
l10ns = concept.localizations || {}
|
|
19
|
+
return [] if l10ns.empty?
|
|
20
|
+
|
|
21
|
+
default = Config.default_language
|
|
22
|
+
return [] if l10ns[default]
|
|
23
|
+
|
|
24
|
+
[issue(
|
|
25
|
+
"#{context.file_name}: no localization in the default " \
|
|
26
|
+
"language '#{default}' (has: #{l10ns.keys.join(', ')})",
|
|
27
|
+
code: code, severity: severity,
|
|
28
|
+
location: context.file_name,
|
|
29
|
+
suggestion: "add a '#{default}' localization or set " \
|
|
30
|
+
"default_language in glossarist.yaml"
|
|
31
|
+
)]
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/glossarist/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: glossarist
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.14.
|
|
4
|
+
version: 2.14.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|
|
@@ -208,6 +208,9 @@ files:
|
|
|
208
208
|
- data/concept-model/glossarist.ttl
|
|
209
209
|
- data/concept-model/prefixes.ttl
|
|
210
210
|
- data/concept-model/shapes/glossarist.shacl.ttl
|
|
211
|
+
- docs/data-format.adoc
|
|
212
|
+
- docs/rich-text.adoc
|
|
213
|
+
- docs/usage.adoc
|
|
211
214
|
- exe/glossarist
|
|
212
215
|
- glossarist.gemspec
|
|
213
216
|
- lib/glossarist.rb
|
|
@@ -451,6 +454,7 @@ files:
|
|
|
451
454
|
- lib/glossarist/validation/rules/dataset_context.rb
|
|
452
455
|
- lib/glossarist/validation/rules/date_type_rule.rb
|
|
453
456
|
- lib/glossarist/validation/rules/date_validity_rule.rb
|
|
457
|
+
- lib/glossarist/validation/rules/default_language_rule.rb
|
|
454
458
|
- lib/glossarist/validation/rules/definition_content_rule.rb
|
|
455
459
|
- lib/glossarist/validation/rules/designation_status_rule.rb
|
|
456
460
|
- lib/glossarist/validation/rules/designation_type_rule.rb
|