metanorma-plugin-glossarist 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -0
- data/README.md +188 -0
- data/lib/metanorma/plugin/glossarist/dataset_preprocessor.rb +21 -3
- data/lib/metanorma/plugin/glossarist/version.rb +1 -1
- data/metanorma-plugin-glossarist.gemspec +1 -5
- metadata +5 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 891bcd6d1ffd87c66fd4d6901e26dde46ee52b93a8feee0e04b4f6f5e0a8d588
|
4
|
+
data.tar.gz: 7cf700c07b974e0b4e17bb02117cfaf38cc6d1b0d7b6fc578025da3faa497412
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a78d34c2063ca08e785f99e2ddcddd93321ea78f9243d1fa537d80dbbbf4aee56639b5739c5ef04e495717a7752d53a43ae4ca530938ef037d8aeec2b9eb4876
|
7
|
+
data.tar.gz: f7f93f41b8883f7648b079f157b2085c5a0300e36b6962a4f08a2fb3a00f4acf8c82c7cadcefe50e7605fa05a10560ad4e4e33986f7ccf35a356231afa65c203
|
data/Gemfile
CHANGED
@@ -4,6 +4,11 @@ Encoding.default_internal = Encoding::UTF_8
|
|
4
4
|
source "https://rubygems.org"
|
5
5
|
git_source(:github) { |repo| "https://github.com/#{repo}" }
|
6
6
|
|
7
|
+
gem "metanorma-standoc"
|
8
|
+
gem "pry"
|
9
|
+
gem "rake", "~> 12.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
|
7
12
|
gemspec
|
8
13
|
|
9
14
|
eval_gemfile("Gemfile.devel") rescue nil
|
data/README.md
CHANGED
@@ -138,6 +138,194 @@ The term bar is used as metasyntactic variables and placeholder names in compute
|
|
138
138
|
The term foo is used as metasyntactic variables and placeholder names in computer programming
|
139
139
|
```
|
140
140
|
|
141
|
+
The full concept model (a concept can have multiple localized concepts) is available through the block as follows:
|
142
|
+
|
143
|
+
```ruby
|
144
|
+
{
|
145
|
+
# UUIDs for localized concept mappings
|
146
|
+
"localized_concepts" => {
|
147
|
+
"eng" => "<uuid>", # English concept UUID
|
148
|
+
"fre" => "<uuid>" # French concept UUID
|
149
|
+
},
|
150
|
+
|
151
|
+
# Main concept term
|
152
|
+
"term" => "<string>",
|
153
|
+
|
154
|
+
# Language-specific content (structure repeated for each language code)
|
155
|
+
"<language_code>" => {
|
156
|
+
"dates" => [], # Array of relevant dates
|
157
|
+
"definition" => [ # Array of definition objects
|
158
|
+
{
|
159
|
+
"content" => "<string>" # Definition text
|
160
|
+
}
|
161
|
+
],
|
162
|
+
"examples" => [], # Array of example objects
|
163
|
+
"id" => "<string>", # Concept ID
|
164
|
+
|
165
|
+
"notes" => [ # Array of note objects
|
166
|
+
{
|
167
|
+
"content" => "<string>" # Note text
|
168
|
+
}
|
169
|
+
],
|
170
|
+
|
171
|
+
"sources" => [ # Array of source objects
|
172
|
+
{
|
173
|
+
"origin" => {
|
174
|
+
"ref" => "<string>" # Reference citation
|
175
|
+
},
|
176
|
+
"type" => "<string>", # Source type (e.g. "lineage")
|
177
|
+
"status" => "<string>" # Status (e.g. "identical")
|
178
|
+
}
|
179
|
+
],
|
180
|
+
|
181
|
+
"terms" => [ # Array of term objects
|
182
|
+
{
|
183
|
+
"type" => "<string>", # Term type (e.g. "expression")
|
184
|
+
"normative_status" => "<string>", # Status (e.g. "preferred")
|
185
|
+
"designation" => "<string>", # Term text
|
186
|
+
"grammar_info" => [ # Array of grammar objects
|
187
|
+
{
|
188
|
+
"preposition" => boolean,
|
189
|
+
"participle" => boolean,
|
190
|
+
"adj" => boolean,
|
191
|
+
"verb" => boolean,
|
192
|
+
"adverb" => boolean,
|
193
|
+
"noun" => boolean,
|
194
|
+
"gender" => ["<string>"], # Array of grammatical genders
|
195
|
+
"number" => ["<string>"] # Array of grammatical numbers
|
196
|
+
}
|
197
|
+
]
|
198
|
+
}
|
199
|
+
],
|
200
|
+
|
201
|
+
"language_code" => "<string>" # ISO language code
|
202
|
+
}
|
203
|
+
}
|
204
|
+
```
|
205
|
+
|
206
|
+
The language codes used are ISO 639-* 3-character codes, as described in the
|
207
|
+
[Glossarist Concept model](https://github.com/glossarist/concept-model).
|
208
|
+
|
209
|
+
An example of the full model (from ISO/IEC 2382:2015):
|
210
|
+
|
211
|
+
```ruby
|
212
|
+
{
|
213
|
+
"localized_concepts" => {
|
214
|
+
"eng" => "01134f51-b88c-5214-8909-5d271ea619cf",
|
215
|
+
"fre" => "f290a3af-f1b3-527a-9045-a2dfcc0caf5a"
|
216
|
+
},
|
217
|
+
"term" => "concept description",
|
218
|
+
"eng" => {
|
219
|
+
"dates" => [],
|
220
|
+
"definition" => [
|
221
|
+
{
|
222
|
+
"content" => "data structure describing the class of all known instances of a concept"
|
223
|
+
}
|
224
|
+
],
|
225
|
+
"examples" => [],
|
226
|
+
"id" => "2122978",
|
227
|
+
"notes" => [
|
228
|
+
{
|
229
|
+
"content" => "concept description: term and definition standardized by ISO/IEC [ISO/IEC 2382-31:1997]."
|
230
|
+
},
|
231
|
+
{
|
232
|
+
"content" => "31.02.02 (2382)"
|
233
|
+
}
|
234
|
+
],
|
235
|
+
"sources" => [
|
236
|
+
{
|
237
|
+
"origin" => {
|
238
|
+
"ref" => "ISO/IEC 2382-31:1997"
|
239
|
+
},
|
240
|
+
"type" => "lineage",
|
241
|
+
"status" => "identical"
|
242
|
+
},
|
243
|
+
{
|
244
|
+
"origin" => {
|
245
|
+
"ref" => "Ranger, Natalie * 2006 * Bureau de la traduction / Translation Bureau * Services linguistiques / Linguistic Services * Bur. dir. Centre de traduction et de terminologie / Dir's Office Translation and Terminology Centre * Div. Citoyenneté et Protection civile / Citizen. & Emergency preparedness Div. * Normalisation terminologique / Terminology Standardization"
|
246
|
+
},
|
247
|
+
"type" => "lineage",
|
248
|
+
"status" => "identical"
|
249
|
+
}
|
250
|
+
],
|
251
|
+
"terms" => [
|
252
|
+
{
|
253
|
+
"type" => "expression",
|
254
|
+
"normative_status" => "preferred",
|
255
|
+
"designation" => "concept description",
|
256
|
+
"grammar_info" => [
|
257
|
+
{
|
258
|
+
"preposition" => false,
|
259
|
+
"participle" => false,
|
260
|
+
"adj" => false,
|
261
|
+
"verb" => false,
|
262
|
+
"adverb" => false,
|
263
|
+
"noun" => false,
|
264
|
+
"gender" => [],
|
265
|
+
"number" => ["singular"]
|
266
|
+
}
|
267
|
+
]
|
268
|
+
}
|
269
|
+
],
|
270
|
+
"language_code" => "eng"
|
271
|
+
},
|
272
|
+
"fre" => {
|
273
|
+
"dates" => [],
|
274
|
+
"definition" => [
|
275
|
+
{
|
276
|
+
"content" => "structure de données qui décrit la classe des instances connues d'un concept"
|
277
|
+
}
|
278
|
+
],
|
279
|
+
"examples" => [],
|
280
|
+
"id" => "2122978",
|
281
|
+
"notes" => [
|
282
|
+
{
|
283
|
+
"content" => "description de concept : terme et définition normalisés par l'ISO/CEI [ISO/IEC 2382-31:1997]."
|
284
|
+
},
|
285
|
+
{
|
286
|
+
"content" => "31.02.02 (2382)"
|
287
|
+
}
|
288
|
+
],
|
289
|
+
"sources" => [
|
290
|
+
{
|
291
|
+
"origin" => {
|
292
|
+
"ref" => "ISO/IEC 2382-31:1997"
|
293
|
+
},
|
294
|
+
"type" => "lineage",
|
295
|
+
"status" => "identical"
|
296
|
+
},
|
297
|
+
{
|
298
|
+
"origin" => {
|
299
|
+
"ref" => "Ranger, Natalie * 2006 * Bureau de la traduction / Translation Bureau * Services linguistiques / Linguistic Services * Bur. dir. Centre de traduction et de terminologie / Dir's Office Translation and Terminology Centre * Div. Citoyenneté et Protection civile / Citizen. & Emergency preparedness Div. * Normalisation terminologique / Terminology Standardization"
|
300
|
+
},
|
301
|
+
"type" => "lineage",
|
302
|
+
"status" => "identical"
|
303
|
+
}
|
304
|
+
],
|
305
|
+
"terms" => [
|
306
|
+
{
|
307
|
+
"type" => "expression",
|
308
|
+
"normative_status" => "preferred",
|
309
|
+
"designation" => "description de concept",
|
310
|
+
"grammar_info" => [
|
311
|
+
{
|
312
|
+
"preposition" => false,
|
313
|
+
"participle" => false,
|
314
|
+
"adj" => false,
|
315
|
+
"verb" => false,
|
316
|
+
"adverb" => false,
|
317
|
+
"noun" => false,
|
318
|
+
"gender" => ["f"],
|
319
|
+
"number" => ["singular"]
|
320
|
+
}
|
321
|
+
]
|
322
|
+
}
|
323
|
+
],
|
324
|
+
"language_code" => "fre"
|
325
|
+
}
|
326
|
+
}
|
327
|
+
```
|
328
|
+
|
141
329
|
### Rendering a single term from loaded dataset
|
142
330
|
|
143
331
|
This can be used to render a single concept from the loaded dataset. See [Loading Dataset](#loading-dataset) to load a dataset.
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "asciidoctor"
|
4
|
-
require "pry"
|
5
4
|
|
6
5
|
require "liquid"
|
7
6
|
require "asciidoctor/reader"
|
@@ -61,7 +60,9 @@ module Metanorma
|
|
61
60
|
super
|
62
61
|
@config = config
|
63
62
|
@datasets = {}
|
63
|
+
@title_depth = { value: 2 }
|
64
64
|
@rendered_bibliographies = {}
|
65
|
+
@seen_glossarist = []
|
65
66
|
end
|
66
67
|
|
67
68
|
def process(document, reader)
|
@@ -74,10 +75,19 @@ module Metanorma
|
|
74
75
|
@config[:file_system] = file_system
|
75
76
|
|
76
77
|
processed_doc = prepare_document(document, input_lines)
|
78
|
+
log(document, processed_doc.to_s) unless @seen_glossarist.empty?
|
77
79
|
Asciidoctor::PreprocessorReader.new(document,
|
78
80
|
processed_doc.to_s.split("\n"))
|
79
81
|
end
|
80
82
|
|
83
|
+
protected
|
84
|
+
|
85
|
+
def log(doc, text)
|
86
|
+
File.open("#{doc.attr('docfile')}.glossarist.log.txt", "w:UTF-8") do |f|
|
87
|
+
f.write(text)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
81
91
|
private
|
82
92
|
|
83
93
|
def prepare_document(document, input_lines, end_mark = nil)
|
@@ -110,11 +120,13 @@ module Metanorma
|
|
110
120
|
elsif match = current_line.match(GLOSSARIST_BLOCK_REGEX)
|
111
121
|
process_glossarist_block(document, liquid_doc, input_lines, match)
|
112
122
|
else
|
123
|
+
@title_depth[:value] = current_line.sub(/ .*$/, "").size if /^==+ \S/.match?(current_line)
|
113
124
|
liquid_doc.add_content(current_line)
|
114
125
|
end
|
115
126
|
end
|
116
127
|
|
117
128
|
def process_dataset_tag(document, input_lines, liquid_doc, match)
|
129
|
+
@seen_glossarist << "x"
|
118
130
|
context_names = prepare_dataset_contexts(document, match[1])
|
119
131
|
|
120
132
|
dataset_section = <<~TEMPLATE
|
@@ -130,6 +142,7 @@ module Metanorma
|
|
130
142
|
end
|
131
143
|
|
132
144
|
def process_glossarist_block(document, liquid_doc, input_lines, match)
|
145
|
+
@seen_glossarist << "x"
|
133
146
|
end_mark = input_lines.next
|
134
147
|
path = relative_file_path(document, match[1])
|
135
148
|
|
@@ -161,6 +174,7 @@ module Metanorma
|
|
161
174
|
end
|
162
175
|
|
163
176
|
def process_render_tag(liquid_doc, match)
|
177
|
+
@seen_glossarist << "x"
|
164
178
|
context_name, concept_name = match[1].split(",")
|
165
179
|
|
166
180
|
liquid_doc.add_content(
|
@@ -169,6 +183,7 @@ module Metanorma
|
|
169
183
|
end
|
170
184
|
|
171
185
|
def process_import_tag(liquid_doc, match)
|
186
|
+
@seen_glossarist << "x"
|
172
187
|
context_name = match[1].strip
|
173
188
|
dataset = @datasets[context_name.strip]
|
174
189
|
|
@@ -180,6 +195,7 @@ module Metanorma
|
|
180
195
|
end
|
181
196
|
|
182
197
|
def process_bibliography(liquid_doc, match)
|
198
|
+
@seen_glossarist << "x"
|
183
199
|
dataset_name = match[1].strip
|
184
200
|
dataset = @datasets[dataset_name]
|
185
201
|
|
@@ -191,6 +207,7 @@ module Metanorma
|
|
191
207
|
end
|
192
208
|
|
193
209
|
def process_bibliography_entry(liquid_doc, match)
|
210
|
+
@seen_glossarist << "x"
|
194
211
|
dataset_name, concept_name = match[1].split(",").map(&:strip)
|
195
212
|
concept = @datasets[dataset_name][concept_name]
|
196
213
|
|
@@ -203,7 +220,7 @@ module Metanorma
|
|
203
220
|
bibliography = concept["eng"]["sources"].map do |source|
|
204
221
|
ref = source["origin"]["ref"]
|
205
222
|
|
206
|
-
next if @rendered_bibliographies[ref]
|
223
|
+
next if @rendered_bibliographies[ref] || ref.nil? || ref.empty?
|
207
224
|
|
208
225
|
@rendered_bibliographies[ref] = ref.gsub(/[ \/:]/, "_")
|
209
226
|
"* [[[#{@rendered_bibliographies[ref]},#{ref}]]]"
|
@@ -238,7 +255,7 @@ module Metanorma
|
|
238
255
|
|
239
256
|
def concept_template(dataset_name, concept_name)
|
240
257
|
<<~CONCEPT_TEMPLATE
|
241
|
-
|
258
|
+
#{"=" * (@title_depth[:value] + 1)} {{ #{dataset_name}['#{concept_name}'].term }}
|
242
259
|
#{alt_terms(dataset_name, concept_name)}
|
243
260
|
|
244
261
|
{{ #{dataset_name}['#{concept_name}']['eng'].definition[0].content }}
|
@@ -290,6 +307,7 @@ module Metanorma
|
|
290
307
|
def sources(dataset_name, concept_name)
|
291
308
|
<<~SOURCES
|
292
309
|
{% for source in #{dataset_name}['#{concept_name}']['eng'].sources %}
|
310
|
+
{%- if source.origin.ref == nil or source.origin.ref == '' %}{% continue %}{% endif %}
|
293
311
|
[.source]
|
294
312
|
<<{{ source.origin.ref | replace: ' ', '_' | replace: '/', '_' | replace: ':', '_' }},{{ source.origin.clause }}>>
|
295
313
|
|
@@ -24,10 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
|
26
26
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
27
|
-
spec.add_dependency "glossarist", "~> 2.0
|
27
|
+
spec.add_dependency "glossarist", "~> 2.0"
|
28
28
|
spec.add_dependency "liquid", "~> 5"
|
29
|
-
|
30
|
-
spec.add_development_dependency "pry"
|
31
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
32
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
33
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-plugin-glossarist
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.0
|
33
|
+
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.0
|
40
|
+
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: liquid
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,48 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: pry
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '12.0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '12.0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '3.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '3.0'
|
97
55
|
description: Metanorma plugin for glossarist
|
98
56
|
email:
|
99
57
|
- open.source@ribose.com
|
@@ -141,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
99
|
- !ruby/object:Gem::Version
|
142
100
|
version: '0'
|
143
101
|
requirements: []
|
144
|
-
rubygems_version: 3.3.
|
102
|
+
rubygems_version: 3.3.27
|
145
103
|
signing_key:
|
146
104
|
specification_version: 4
|
147
105
|
summary: Metanorma plugin for glossarist
|