glossarist 2.14.13 → 2.14.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32f3a43314ed25f2063cafcdebfc76d4ae45e7f43f11880879583eb38e611bf8
4
- data.tar.gz: ba504e2696fc2fb1730cdf069a1bb0cde9b7c7a957db19f8be9fdc21a84b6675
3
+ metadata.gz: 655f02b361ee905c65608800454cda81b99801df1abf0432527d81e0a664ee51
4
+ data.tar.gz: 2af428ac0c45bf6dacb03dd93c5c325dcfd04b63263f2704eeda13371319fd38
5
5
  SHA512:
6
- metadata.gz: ff8a7a6aea44bfd0f0f5dd1506c45702de9087cf69d6493c371d37319a71d92d414ccc4184a66d04c8a3d42d3ff26576831fcdb7cca9b4a45eab58358e9d0333
7
- data.tar.gz: 0b1c5724fe8dce21ecc19c4b96ab6010703775f382c6273e435a5945a88b8cfb665146115d21de3d713c7fea1428d14945fb2545bca23b7bd3d50d70ebcd51a8
6
+ metadata.gz: 98bec4dd3f9d1db11a79391ec081ca840ca1dd6c1b5b33a6cc0bfe066989c6d7f52b2ca3787fed77ef0e75e96bc0e999e6ced1965c0872c3debffbc316a6f365
7
+ data.tar.gz: 8430eebf7f31174bd40959db9826a0bb334452cc4ce8560853d42c936e2964de25a404094d1766bdbfef12325f81d05f77b514dea7c3a842f8fc0bd6fc943746
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,212 @@
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, named `<slug>.yaml` under the comprehensive concept's id:
154
+
155
+ [,yaml]
156
+ ----
157
+ ---
158
+ comprehensive:
159
+ ref: urn:my-glossary:concept:3a75582e-...
160
+ partitives:
161
+ - ref: urn:my-glossary:concept:4b0e2358-...
162
+ multiplicity: compulsory # or optional / compulsory_multiple / ...
163
+ is_delimiting: false
164
+ - ref: urn:my-glossary:concept:5c1f3469-...
165
+ completeness: complete # or partial
166
+ criterion:
167
+ eng: physical structure
168
+ ----
169
+
170
+ ISO 704 requires at least two partitives; `Validation::Rules` enforces structural invariants (GLS-2xx series).
171
+
172
+ == bibliography.yaml
173
+
174
+ The V3 wrapper-key form — a single mapping whose one key wraps an ordered array of typed entries:
175
+
176
+ [,yaml]
177
+ ----
178
+ bibliography:
179
+ - id: iso-10241-1
180
+ type: citation
181
+ citation:
182
+ ref: ISO 10241-1
183
+ type: international-standard
184
+ bibdata:
185
+ ...relaton bibliography item...
186
+ ----
187
+
188
+ `bibdata` carries a Relaton bibliography item; the wrapper form is glossarist's own wire shape and is not Relaton's format.
189
+
190
+ == Non-verbal entities (figures/, tables/, formulas/)
191
+
192
+ One typed document per file, referenced from concept data via `FigureReference`/`TableReference`/`FormulaReference`:
193
+
194
+ [,yaml]
195
+ ----
196
+ id: fig-1
197
+ image: images/fig-1.png
198
+ label: Figure 1
199
+ ----
200
+
201
+ == Default language
202
+
203
+ The dataset's primary language defaults to `"eng"`. It is customizable:
204
+
205
+ * per dataset: `default_language: <ISO 639>` in `glossarist.yaml` in the working directory, or
206
+ * programmatically: `Glossarist.config.default_language = "deu"`.
207
+
208
+ `ManagedConcept#default_lang` returns the default-language localization, and validation rule GLS-311 requires a concept with localizations to carry one in that language.
209
+
210
+ == Packaging (.gcr)
211
+
212
+ `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.
@@ -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]).
@@ -32,7 +32,9 @@ module Glossarist
32
32
 
33
33
  def to_managed_concept
34
34
  mc = concept
35
- localizations.each { |l10n| mc.add_localization(l10n) }
35
+ # Files without a localizations key deserialize with a nil
36
+ # collection; treat that as empty.
37
+ (localizations || []).each { |l10n| mc.add_localization(l10n) }
36
38
  mc
37
39
  end
38
40
 
@@ -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
@@ -141,7 +141,7 @@ module Glossarist
141
141
  end
142
142
 
143
143
  def default_lang
144
- localization("eng") || localizations.values.first
144
+ localization(Config.default_language) || localizations.values.first
145
145
  end
146
146
 
147
147
  def all_sources
@@ -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
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.14.13"
7
+ VERSION = "2.14.15"
8
8
  end
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.13
4
+ version: 2.14.15
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-06 00:00:00.000000000 Z
11
+ date: 2026-11-10 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