glossarist 2.0.1 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +319 -2
- data/lib/glossarist/concept_manager.rb +2 -2
- data/lib/glossarist/managed_concept.rb +12 -0
- data/lib/glossarist/managed_concept_collection.rb +2 -0
- data/lib/glossarist/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db3243d2a3dee8ab236ac591b088e291f735880421d586cb7b08881b023c7b4
|
4
|
+
data.tar.gz: 4973495641223a4f88cc5c8c83c239c4979d94d77a8986dfaceaf3165ba78a6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b731a9514198432b603978107243ab700657c5738a17a4b7a8db543fb92d4fa9f6db0f8b56c3a75b90e8a371f43d2ba2c70de494a2b393185621ad35e0014496
|
7
|
+
data.tar.gz: 852a6dc42b6332816ddbaeb73eefbb21071c685e9965337100f926a53025e892b938141ecb227c43eb662f614a1d459294860dae0745ab025642d4a1c358201a
|
data/README.adoc
CHANGED
@@ -1,11 +1,328 @@
|
|
1
|
+
:glossarist_model_url: https://github.com/glossarist/concept-model/tree/main
|
2
|
+
:glossarist_model_v2_schema_url: https://github.com/glossarist/concept-model/tree/main/yaml_schemas
|
3
|
+
|
1
4
|
= Glossarist
|
2
5
|
|
6
|
+
Glossarist gem implements the {glossarist_model_url}[Glossarist model] in ruby. All the entities in the model are available as classes and all the attributes are available as methods of those classes.
|
7
|
+
This gem also allows you to read/write data to concept dataset or create your own collection and save that to glossarist model V2 dataset.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
[,ruby]
|
14
|
+
----
|
15
|
+
gem 'glossarist'
|
16
|
+
----
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
[,bash]
|
20
|
+
----
|
21
|
+
bundle install
|
22
|
+
----
|
23
|
+
|
24
|
+
Or install it yourself as:
|
25
|
+
[,bash]
|
26
|
+
----
|
27
|
+
gem install glossarist
|
28
|
+
----
|
29
|
+
|
30
|
+
== Usage
|
31
|
+
|
32
|
+
=== Reading a Glossarist model V2 from files
|
33
|
+
|
34
|
+
To load the glossarist model V2 dataset
|
35
|
+
|
36
|
+
[,ruby]
|
37
|
+
----
|
38
|
+
collection = Glossarist::ManagedConceptCollection.new
|
39
|
+
collection.load_from_files("path/to/glossarist-v2-dataset")
|
40
|
+
----
|
41
|
+
|
42
|
+
=== Writing a Glossarist model V2 to files
|
43
|
+
|
44
|
+
To wite the glossarist model V2 dataset to files
|
45
|
+
|
46
|
+
[,ruby]
|
47
|
+
----
|
48
|
+
collection = Glossarist::ManagedConceptCollection.new
|
49
|
+
collection.load_from_files("path/to/glossarist-v2-dataset")
|
50
|
+
|
51
|
+
# ... Update the collection ...
|
52
|
+
|
53
|
+
collection.save_to_files("path/to/glossarist-v2-dataset")
|
54
|
+
----
|
55
|
+
|
56
|
+
=== ManagedConceptCollection
|
57
|
+
|
58
|
+
This is a collection for <<managed-concept,managed concepts>>. It includes the ruby 'Enumerable' module.
|
59
|
+
|
60
|
+
[,ruby]
|
61
|
+
----
|
62
|
+
collection = Glossarist::ManagedConceptCollection.new
|
63
|
+
----
|
64
|
+
|
65
|
+
[[id,managed-concept]]
|
66
|
+
=== ManagedConcept
|
67
|
+
|
68
|
+
Following fields are available for ManagedConcept:
|
69
|
+
|
70
|
+
id:: String identifier for the concept
|
71
|
+
uuid:: UUID for the concept
|
72
|
+
related:: Array of <<related-concept,RelatedConcept>>
|
73
|
+
status:: Enum for the normative status of the term.
|
74
|
+
dates:: Array of <<concept-date,ConceptDate>>
|
75
|
+
localized_concepts:: Hash of all localizations where keys are language codes and values are uuid of the localized concept.
|
76
|
+
groups:: Array of groups in string format
|
77
|
+
localizations:: Hash of all localizations for this concept where keys are language codes and values are instances of <<localized-concept,LocalizedConcept>>.
|
78
|
+
|
79
|
+
There are two ways to initialize and populate a managed concept
|
80
|
+
|
81
|
+
1. Setting the fields by using a hash while initializing
|
82
|
+
+
|
83
|
+
[,ruby]
|
84
|
+
----
|
85
|
+
concept = Glossarist::ManagedConcept.new({
|
86
|
+
"data" => {
|
87
|
+
"id" => "123",
|
88
|
+
"localized_concepts" => {
|
89
|
+
"ara" => "<uuid>",
|
90
|
+
"eng" => "<uuid>"
|
91
|
+
},
|
92
|
+
"localizations" => <Array of localized concepts or localized concept hashes>,
|
93
|
+
"groups" => [
|
94
|
+
"foo",
|
95
|
+
"bar",
|
96
|
+
],
|
97
|
+
},
|
98
|
+
})
|
99
|
+
----
|
100
|
+
|
101
|
+
2. Setting the fields after creating an object
|
102
|
+
+
|
103
|
+
[,ruby]
|
104
|
+
----
|
105
|
+
concept = Glossarist::ManagedConcept.new
|
106
|
+
concept.id = "123"
|
107
|
+
concept.groups = ["foo", "bar"]
|
108
|
+
concept.localizations = <Array of localized concepts or localized concept hashes>
|
109
|
+
----
|
110
|
+
|
111
|
+
[[id,localized-concept]]
|
112
|
+
=== LocalizedConcept
|
113
|
+
|
114
|
+
Localizations of the term to different languages.
|
115
|
+
|
116
|
+
Localized concept has the following fields
|
117
|
+
|
118
|
+
id:: An optional identifier for the term, to be used in cross-references.
|
119
|
+
uuid:: UUID for the concept
|
120
|
+
designations:: Array of <<designation,Designations>> under which the term being defined is known. This method will also accept an array of hashes for designation and will convert them to their respective classes.
|
121
|
+
domain:: An optional semantic domain for the term being defined, in case the term is ambiguous between several semantic domains.
|
122
|
+
subject:: Subject of the term.
|
123
|
+
definition:: Array of <<detailed-definition,Detailed Definition>> of the term.
|
124
|
+
non_verb_rep:: Array of <<non-verbal,non-verbal>> representations used to help define the term.
|
125
|
+
notes:: Zero or more notes about the term. A note is in <<detailed-definition,Detailed Definition>> format.
|
126
|
+
examples:: Zero or more examples of how the term is to be used in <<detailed-definition,Detailed Definition>> format.
|
127
|
+
language_code:: The language of the localization, as an ISO-639 3-letter code.
|
128
|
+
entry_status:: Entry status of the concept. Must be one of the following: +notValid+, +valid+, +superseded+, +retired+.
|
129
|
+
classification:: Classification of the concept. Must be one of the following: +preferred+, +admitted+, +deprecated+.
|
130
|
+
|
131
|
+
[[id,designation]]
|
132
|
+
=== Designation::Base
|
133
|
+
|
134
|
+
A name under which a managed term is known.
|
135
|
+
|
136
|
+
Methods::
|
137
|
+
`from_h(options)`::: Creates a new designation instance based on the specified type.
|
138
|
+
|
139
|
+
Parameters::
|
140
|
+
* options (Hash) - The options for creating the designation.
|
141
|
+
* "type" (String) - The type of designation (expression, symbol, abbreviation, graphical_symbol, letter_symbol). Note: type key should be string and not a symbol so { type: "expression" } will not work.
|
142
|
+
* Additional options depend on the specific designation type.
|
143
|
+
|
144
|
+
Returns::
|
145
|
+
Designation::{type}::: A new instance of specified type. e.g `Glossarist::Designation::Base.from_h("type" => "expression")` will return `Glossarist::Designation::Expression`
|
146
|
+
|
147
|
+
Example
|
148
|
+
[,ruby]
|
149
|
+
----
|
150
|
+
# Example usage of Designation::Base class
|
151
|
+
|
152
|
+
attributes_for_expression = { designation: "foobar", geographical_area: "abc", normative_status: "status" }
|
153
|
+
designation_expression = Designation::Base.from_h({ "type" => "expression" }.merge(attributes_for_expression))
|
154
|
+
|
155
|
+
attributes_for_abbreviation = { designation: "foobar", geographical_area: "abc", normative_status: "status", international: true }
|
156
|
+
designation_abbreviation = Designation::Base.from_h({ "type" => "abbreviation" }.merge(attributes_for_abbreviation))
|
157
|
+
|
158
|
+
----
|
159
|
+
|
160
|
+
[[id,related-concept]]
|
161
|
+
=== RelatedConcept
|
162
|
+
|
163
|
+
A term related to the current term.
|
164
|
+
|
165
|
+
Following fields are available for the Related Concept
|
166
|
+
|
167
|
+
type:: An enum to denote the relation of the term to the current term.
|
168
|
+
content:: The designation of the related term.
|
169
|
+
ref:: A <<citation, citation>> of the related term, in a Termbase.
|
170
|
+
|
171
|
+
There are two ways to initialize and populate a related concept
|
172
|
+
|
173
|
+
1. Setting the fields by using a hash while initializing
|
174
|
+
+
|
175
|
+
[,ruby]
|
176
|
+
----
|
177
|
+
related_concept = Glossarist::RelatedConcept.new({
|
178
|
+
content: "Test content",
|
179
|
+
type: :supersedes,
|
180
|
+
ref: <concept citation>
|
181
|
+
})
|
182
|
+
----
|
183
|
+
|
184
|
+
2. Setting the fields after creating an object
|
185
|
+
+
|
186
|
+
[,ruby]
|
187
|
+
----
|
188
|
+
related_concept = Glossarist::RelatedConcept.new
|
189
|
+
related_concept.type = "supersedes"
|
190
|
+
related_concept.content = "designation of the related concept"
|
191
|
+
related_concept.ref = <Citation object>
|
192
|
+
----
|
193
|
+
|
194
|
+
[[id,concept-date]]
|
195
|
+
=== Concept Date
|
196
|
+
|
197
|
+
A date relevant to the lifecycle of the managed term.
|
198
|
+
|
199
|
+
Following fields are available for the Concept Date
|
200
|
+
|
201
|
+
- date: The date associated with the managed term in Iso8601Date format.
|
202
|
+
- type: An enum to denote the event which occured on the given date and associated with the lifecycle of the managed term.
|
203
|
+
|
204
|
+
There are two ways to initialize and populate a concept date
|
205
|
+
|
206
|
+
1. Setting the fields by using a hash while initializing
|
207
|
+
+
|
208
|
+
[,ruby]
|
209
|
+
----
|
210
|
+
concept_date = Glossarist::ConceptDate.new({
|
211
|
+
date: "2010-11-01T00:00:00.000Z",
|
212
|
+
type: :accepted,
|
213
|
+
})
|
214
|
+
----
|
215
|
+
|
216
|
+
2. Setting the fields after creating an object
|
217
|
+
+
|
218
|
+
[,ruby]
|
219
|
+
----
|
220
|
+
concept_date = Glossarist::ConceptDate.new
|
221
|
+
concept_date.type = :accepted
|
222
|
+
concept_date.date = "2010-11-01T00:00:00.000Z"
|
223
|
+
----
|
224
|
+
|
225
|
+
[[id,detailed-definition]]
|
226
|
+
=== DetailedDefinition
|
227
|
+
|
228
|
+
A definition of the managed term.
|
229
|
+
|
230
|
+
It has the following attributes:
|
231
|
+
|
232
|
+
content:: The text of the definition of the managed term.
|
233
|
+
sources:: List of Bibliographic references(<<citation,Citation>>) for this particular definition of the managed term.
|
234
|
+
|
235
|
+
There are two ways to initialize and populate a detailed definition
|
236
|
+
|
237
|
+
1. Setting the fields by using a hash while initializing
|
238
|
+
+
|
239
|
+
[,ruby]
|
240
|
+
----
|
241
|
+
detailed_definition = Glossarist::DetailedDefinition.new({
|
242
|
+
content: "plain text reference",
|
243
|
+
sources: [<list of citations>],
|
244
|
+
})
|
245
|
+
----
|
246
|
+
|
247
|
+
2. Setting the fields after creating an object
|
248
|
+
+
|
249
|
+
[,ruby]
|
250
|
+
----
|
251
|
+
detailed_definition = Glossarist::DetailedDefinition.new
|
252
|
+
detailed_definition.content = "plain text reference",
|
253
|
+
detailed_definition.sources = [<list of citations>]
|
254
|
+
----
|
255
|
+
|
256
|
+
[[id,citation]]
|
257
|
+
=== Citation
|
258
|
+
|
259
|
+
Citation can be either structured or unstructured. A citation is structured if its reference contains one or all of the following keys `{ id: "id", source: "source", version: "version"}` and is unstructured if its reference is plain text. This also has 2 methods `structured?` and `plain?` to check if citation is structured or not.
|
260
|
+
|
261
|
+
Citation has the following attributes.
|
262
|
+
|
263
|
+
ref:: A hash or string based on type of citation. Hash if citation is structured or string if citation is plain.
|
264
|
+
clause:: Referred clause of the document.
|
265
|
+
link:: Link to document.
|
266
|
+
|
267
|
+
There are two ways to initialize and populate a Citation
|
268
|
+
|
269
|
+
1. Setting the fields by using a hash while initializing
|
270
|
+
+
|
271
|
+
[,ruby]
|
272
|
+
----
|
273
|
+
# Unstructured Citation
|
274
|
+
citation = Glossarist::Citation.new({
|
275
|
+
ref: "plain text reference",
|
276
|
+
clause: "clause",
|
277
|
+
link: "link",
|
278
|
+
})
|
279
|
+
|
280
|
+
# Structured Citation
|
281
|
+
citation = Glossarist::Citation.new({
|
282
|
+
ref: { id: "123", source: "source", version: "1.1" },
|
283
|
+
clause: "clause",
|
284
|
+
link: "link",
|
285
|
+
})
|
286
|
+
----
|
287
|
+
|
288
|
+
2. Setting the fields after creating an object
|
289
|
+
+
|
290
|
+
[,ruby]
|
291
|
+
----
|
292
|
+
citation = Glossarist::Citation.new
|
293
|
+
citation.ref = <plain or structured ref>
|
294
|
+
citation.clause = "some clause"
|
295
|
+
----
|
296
|
+
|
297
|
+
=== NonVerbRep
|
298
|
+
|
299
|
+
Non-verbal Representation have the following fields
|
300
|
+
|
301
|
+
image:: An image used to help define a term.
|
302
|
+
table:: A table used to help define a term.
|
303
|
+
formula:: A formula used to help define a term.
|
304
|
+
sources:: Bibliographic <<concept-source,concept source>> for the non-verbal representation of the term.
|
305
|
+
|
306
|
+
[[id,concept-source]]
|
307
|
+
=== ConceptSource
|
308
|
+
|
309
|
+
Concept Source has the following fields
|
310
|
+
|
311
|
+
status:: The status of the managed term in the present context, relative to the term as found in the bibliographic source.
|
312
|
+
type:: The type of the managed term in the present context.
|
313
|
+
origin:: The bibliographic <<citation,citation>> for the managed term. This is also aliased as `ref`.
|
314
|
+
modification:: A description of the modification to the cited definition of the term, if any, as it is to be applied in the present context.
|
315
|
+
|
316
|
+
|
3
317
|
== Commands
|
4
318
|
|
5
|
-
`generate_latex
|
319
|
+
`generate_latex`:: Convert Concepts to Latex format
|
6
320
|
|
7
321
|
=== Usage:
|
8
|
-
|
322
|
+
[,bash]
|
323
|
+
----
|
324
|
+
glossarist generate_latex p, --concepts-path=CONCEPTS_PATH
|
325
|
+
----
|
9
326
|
|
10
327
|
=== Options:
|
11
328
|
[cols="1,1"]
|
@@ -33,7 +33,7 @@ module Glossarist
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def load_concept_from_file(filename)
|
36
|
-
concept_hash = Psych.safe_load(File.read(filename), permitted_classes: [Date])
|
36
|
+
concept_hash = Psych.safe_load(File.read(filename), permitted_classes: [Date, Time])
|
37
37
|
concept_hash["uuid"] = concept_hash["id"] || File.basename(filename, ".*")
|
38
38
|
|
39
39
|
concept = ManagedConcept.new(concept_hash)
|
@@ -50,7 +50,7 @@ module Glossarist
|
|
50
50
|
def load_localized_concept(id)
|
51
51
|
concept_hash = Psych.safe_load(
|
52
52
|
File.read(localized_concept_path(id)),
|
53
|
-
permitted_classes: [Date],
|
53
|
+
permitted_classes: [Date, Time],
|
54
54
|
)
|
55
55
|
concept_hash["uuid"] = id
|
56
56
|
|
@@ -28,6 +28,10 @@ module Glossarist
|
|
28
28
|
# @return [Array<String>]
|
29
29
|
attr_reader :groups
|
30
30
|
|
31
|
+
# List of authorative sources.
|
32
|
+
# @return [Array<ConceptSource>]
|
33
|
+
attr_reader :sources
|
34
|
+
|
31
35
|
# All localizations for this concept.
|
32
36
|
#
|
33
37
|
# Keys are language codes and values are instances of {LocalizedConcept}.
|
@@ -87,6 +91,12 @@ module Glossarist
|
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
94
|
+
def sources=(sources)
|
95
|
+
@sources = sources&.map do |source|
|
96
|
+
ConceptSource.new(source)
|
97
|
+
end || []
|
98
|
+
end
|
99
|
+
|
90
100
|
def localizations=(localizations)
|
91
101
|
return unless localizations
|
92
102
|
|
@@ -134,6 +144,7 @@ module Glossarist
|
|
134
144
|
"identifier" => id,
|
135
145
|
"localized_concepts" => localized_concepts.empty? ? nil : localized_concepts,
|
136
146
|
"groups" => groups,
|
147
|
+
"sources" => sources&.map(&:to_h),
|
137
148
|
}.compact,
|
138
149
|
}.compact
|
139
150
|
end
|
@@ -182,6 +193,7 @@ module Glossarist
|
|
182
193
|
localizedConcepts
|
183
194
|
localizations
|
184
195
|
groups
|
196
|
+
sources
|
185
197
|
].compact
|
186
198
|
end
|
187
199
|
|
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.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: relaton
|