glossarist 2.10.2 → 2.10.4

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: ca7052a9422ffb06503b2e168e8b6bac1c1ed2fb814c82317d923acbdfa77e7e
4
- data.tar.gz: 87e4729f1b8263e032c4e18bfd663ef3e0af53a14473e2499d1b6828e0b7d61c
3
+ metadata.gz: 960e57fbb569a743b442c15d27edffbe1f88f9ab77ba829b8248149f345604b8
4
+ data.tar.gz: f6540a66baefa0e6b4acf90224019f9a5aa0e58cd0c87c3b56f7b03934fc7114
5
5
  SHA512:
6
- metadata.gz: 85077694000c2d75d7cd7ce1880b920f76f7fcbe9f4d7676e30a2dcb486f553d1d6ddf5cc21fba54b4fef02307dc906866062c080807df6e81c069269b833c30
7
- data.tar.gz: 7cd8fd6e74a4006b6f66c22d98f067e21d58d65f74b1c5cc49307656537e4d3a4ff438a819e537a1d795f6fdefff5affe3255dacc9a5b7cc76dc9207d43f940b
6
+ metadata.gz: 6d1de596f69a5ca4fcfc87bdd15f9af8a26132bd44da7c0ab2ffbe2acfefac9b0c029ba865eb2653dd9039de902c6c6296ea7cbebc15bc0f5a9988b05d64f176
7
+ data.tar.gz: 192f9e5ced2dfe77707c8ff4f43836d639493c16e9928599229f5df80ac0f8271401c038e6402ce1156fd263a39b2b82e5b7ae76d24729871be2c98b6bf14217
@@ -51,6 +51,9 @@ module Glossarist
51
51
 
52
52
  class GlossDocument < Lutaml::Model::Serializable
53
53
  attribute :concepts, GlossConcept, collection: true
54
+ attribute :figures, GlossFigure, collection: true
55
+ attribute :tables, GlossTable, collection: true
56
+ attribute :formulas, GlossFormula, collection: true
54
57
 
55
58
  rdf do
56
59
  namespace Namespaces::GlossaristNamespace,
@@ -61,6 +64,9 @@ module Glossarist
61
64
  Namespaces::RdfNamespace
62
65
 
63
66
  members :concepts
67
+ members :figures
68
+ members :tables
69
+ members :formulas
64
70
  end
65
71
  end
66
72
  end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Glossarist
6
+ module Rdf
7
+ # RDF view for a dataset-level Figure entity (concept-model v3.1.0 K1).
8
+ #
9
+ # Emits a `gloss:Figure` subject with:
10
+ # - gloss:image — xsd:anyURI (the first image variant's src)
11
+ # - gloss:caption — xsd:string (one language picked from the localized hash)
12
+ # - dcterms:description — xsd:string (one language picked)
13
+ #
14
+ # The Figure domain model (Glossarist::Figure) stores caption/description
15
+ # as language-keyed hashes; the K1 FigureShape constrains them to single
16
+ # xsd:string values, so the transform picks one language at build time.
17
+ class GlossFigure < Lutaml::Model::Serializable
18
+ attribute :id, :string
19
+ attribute :identifier, :string
20
+ attribute :image, :string
21
+ attribute :caption, :string
22
+ attribute :description, :string
23
+
24
+ rdf do
25
+ namespace Namespaces::GlossaristNamespace,
26
+ Namespaces::DctermsNamespace
27
+
28
+ subject { |f| "figure/#{f.id}" }
29
+
30
+ types "gloss:Figure"
31
+
32
+ predicate :image, namespace: Namespaces::GlossaristNamespace,
33
+ to: :image
34
+ predicate :caption, namespace: Namespaces::GlossaristNamespace,
35
+ to: :caption
36
+ predicate :description, namespace: Namespaces::DctermsNamespace,
37
+ to: :description
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Glossarist
6
+ module Rdf
7
+ # RDF view for a dataset-level Formula entity (concept-model v3.1.0 K1).
8
+ #
9
+ # Emits a `gloss:Formula` subject with:
10
+ # - gloss:expression — xsd:string (one language picked from the localized hash)
11
+ # - gloss:latexForm — xsd:string (the LaTeX form, when notation is latex)
12
+ # - dcterms:description — xsd:string (one language picked)
13
+ class GlossFormula < Lutaml::Model::Serializable
14
+ attribute :id, :string
15
+ attribute :identifier, :string
16
+ attribute :expression, :string
17
+ attribute :latex_form, :string
18
+ attribute :description, :string
19
+
20
+ rdf do
21
+ namespace Namespaces::GlossaristNamespace,
22
+ Namespaces::DctermsNamespace
23
+
24
+ subject { |f| "formula/#{f.id}" }
25
+
26
+ types "gloss:Formula"
27
+
28
+ predicate :expression, namespace: Namespaces::GlossaristNamespace,
29
+ to: :expression
30
+ predicate :latexForm, namespace: Namespaces::GlossaristNamespace,
31
+ to: :latex_form
32
+ predicate :description, namespace: Namespaces::DctermsNamespace,
33
+ to: :description
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lutaml/model"
4
+
5
+ module Glossarist
6
+ module Rdf
7
+ # RDF view for a dataset-level Table entity (concept-model v3.1.0 K1).
8
+ #
9
+ # Emits a `gloss:Table` subject with:
10
+ # - gloss:content — xsd:string (serialized table content)
11
+ # - gloss:caption — xsd:string (one language picked)
12
+ # - dcterms:title — xsd:string (the table identifier, used as title)
13
+ class GlossTable < Lutaml::Model::Serializable
14
+ attribute :id, :string
15
+ attribute :identifier, :string
16
+ attribute :content, :string
17
+ attribute :caption, :string
18
+
19
+ rdf do
20
+ namespace Namespaces::GlossaristNamespace,
21
+ Namespaces::DctermsNamespace
22
+
23
+ subject { |t| "table/#{t.id}" }
24
+
25
+ types "gloss:Table"
26
+
27
+ predicate :content, namespace: Namespaces::GlossaristNamespace,
28
+ to: :content
29
+ predicate :caption, namespace: Namespaces::GlossaristNamespace,
30
+ to: :caption
31
+ predicate :title, namespace: Namespaces::DctermsNamespace,
32
+ to: :identifier
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Glossarist
4
+ module Rdf
5
+ module Namespaces
6
+ class DcatNamespace < Lutaml::Rdf::Namespace
7
+ uri "http://www.w3.org/ns/dcat#"
8
+ prefix "dcat"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Glossarist
4
+ module Rdf
5
+ module Namespaces
6
+ class FoafNamespace < Lutaml::Rdf::Namespace
7
+ uri "http://xmlns.com/foaf/0.1/"
8
+ prefix "foaf"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -30,6 +30,9 @@ module Glossarist
30
30
  autoload :GlossLocalizedConcept, "#{__dir__}/rdf/gloss_localized_concept"
31
31
  autoload :GlossConcept, "#{__dir__}/rdf/gloss_concept"
32
32
  autoload :GlossDocument, "#{__dir__}/rdf/gloss_concept"
33
+ autoload :GlossFigure, "#{__dir__}/rdf/gloss_figure"
34
+ autoload :GlossTable, "#{__dir__}/rdf/gloss_table"
35
+ autoload :GlossFormula, "#{__dir__}/rdf/gloss_formula"
33
36
  autoload :V3, "#{__dir__}/rdf/v3"
34
37
  end
35
38
  end
@@ -37,8 +37,10 @@ module Glossarist
37
37
  new(managed_concept, options).build
38
38
  end
39
39
 
40
- def self.transform_document(concepts, options = {})
41
- new(nil, options).build_document(concepts)
40
+ def self.transform_document(concepts, figures: [], tables: [],
41
+ formulas: [], **options)
42
+ new(nil, options).build_document(concepts, figures: figures,
43
+ tables: tables, formulas: formulas)
42
44
  end
43
45
 
44
46
  def initialize(managed_concept, options = {})
@@ -50,9 +52,14 @@ module Glossarist
50
52
  build_gloss_concept(concept)
51
53
  end
52
54
 
53
- def build_document(concepts)
55
+ def build_document(concepts, figures: [], tables: [], formulas: [])
54
56
  gloss_concepts = concepts.map { |c| build_gloss_concept(c) }
55
- doc = Rdf::GlossDocument.new(concepts: gloss_concepts)
57
+ doc = Rdf::GlossDocument.new(
58
+ concepts: gloss_concepts,
59
+ figures: figures.map { |f| build_gloss_figure(f) },
60
+ tables: tables.map { |t| build_gloss_table(t) },
61
+ formulas: formulas.map { |f| build_gloss_formula(f) },
62
+ )
56
63
  Rdf::GlossDocument.to_turtle(doc)
57
64
  end
58
65
 
@@ -353,6 +360,61 @@ desig_index)
353
360
  def status_uri(status)
354
361
  status ? "gloss:status/#{status}" : nil
355
362
  end
363
+
364
+ # ── Dataset-level non-verbal entity builders (concept-model v3.1.0 K1) ──
365
+ #
366
+ # The K1 shapes (FigureShape, TableShape, FormulaShape) constrain
367
+ # caption/description to a single xsd:string per subject. The domain
368
+ # models store these as language-keyed hashes; we pick one language
369
+ # (defaulting to eng, falling back to the first available) at build
370
+ # time. Multi-language emission would require per-language subjects,
371
+ # which is beyond K1's scope.
372
+
373
+ DEFAULT_RDF_LANG = "eng"
374
+
375
+ def build_gloss_figure(figure)
376
+ Rdf::GlossFigure.new(
377
+ id: figure.id,
378
+ identifier: figure.identifier,
379
+ image: figure.images.first&.src,
380
+ caption: localized_pick(figure.caption),
381
+ description: localized_pick(figure.description),
382
+ )
383
+ end
384
+
385
+ def build_gloss_table(table)
386
+ Rdf::GlossTable.new(
387
+ id: table.id,
388
+ identifier: table.identifier,
389
+ content: serialize_table_content(table.content),
390
+ caption: localized_pick(table.caption),
391
+ )
392
+ end
393
+
394
+ def build_gloss_formula(formula)
395
+ expression_str = localized_pick(formula.expression)
396
+ Rdf::GlossFormula.new(
397
+ id: formula.id,
398
+ identifier: formula.identifier,
399
+ expression: expression_str,
400
+ latex_form: formula.notation == "latex" ? expression_str : nil,
401
+ description: localized_pick(formula.description),
402
+ )
403
+ end
404
+
405
+ def localized_pick(localized_hash)
406
+ return nil unless localized_hash.is_a?(Hash) && !localized_hash.empty?
407
+
408
+ localized_hash[DEFAULT_RDF_LANG] ||
409
+ localized_hash[DEFAULT_RDF_LANG.to_sym] ||
410
+ localized_hash.values.first
411
+ end
412
+
413
+ def serialize_table_content(content)
414
+ return nil if content.nil?
415
+
416
+ content.is_a?(Hash) ? content.to_yaml : content.to_s
417
+ end
356
418
  end
357
419
  end
358
420
  end
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.10.2"
7
+ VERSION = "2.10.4"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glossarist
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.10.2
4
+ version: 2.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
@@ -303,16 +303,21 @@ files:
303
303
  - lib/glossarist/rdf/gloss_concept_source.rb
304
304
  - lib/glossarist/rdf/gloss_designation.rb
305
305
  - lib/glossarist/rdf/gloss_detailed_definition.rb
306
+ - lib/glossarist/rdf/gloss_figure.rb
307
+ - lib/glossarist/rdf/gloss_formula.rb
306
308
  - lib/glossarist/rdf/gloss_grammar_info.rb
307
309
  - lib/glossarist/rdf/gloss_locality.rb
308
310
  - lib/glossarist/rdf/gloss_localized_concept.rb
309
311
  - lib/glossarist/rdf/gloss_non_verbal_rep.rb
310
312
  - lib/glossarist/rdf/gloss_pronunciation.rb
311
313
  - lib/glossarist/rdf/gloss_reference.rb
314
+ - lib/glossarist/rdf/gloss_table.rb
312
315
  - lib/glossarist/rdf/localized_literal.rb
313
316
  - lib/glossarist/rdf/lutaml_ext.rb
314
317
  - lib/glossarist/rdf/namespaces.rb
318
+ - lib/glossarist/rdf/namespaces/dcat_namespace.rb
315
319
  - lib/glossarist/rdf/namespaces/dcterms_namespace.rb
320
+ - lib/glossarist/rdf/namespaces/foaf_namespace.rb
316
321
  - lib/glossarist/rdf/namespaces/glossarist_namespace.rb
317
322
  - lib/glossarist/rdf/namespaces/iso_thes_namespace.rb
318
323
  - lib/glossarist/rdf/namespaces/owl_namespace.rb