glossarist 2.8.5 → 2.8.7

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: bb636339e439da216185715fcfe387842aabd1b38147dd49b5e4fdb5909b6d2d
4
- data.tar.gz: 2704b81c1f4d179d8909bc1d245b9caee83d2e54fa56a6148699892f021e9d6f
3
+ metadata.gz: b6de74f1a2e3c9d3379f35ccf94a46a0d407149329e27fa95521e40e8a22c883
4
+ data.tar.gz: 2159f19a3d6c355b7bafba1f76d3f673fe3a0813af919479c1835dbcd609dbd7
5
5
  SHA512:
6
- metadata.gz: 5e39df7a02295426fb6463f93189cf6e3d457e60457b9bb5cde1881eeb549fe1afd4730e3ac280030be8de60734dbc2e0532b14030890e107b9df35dabbd1ede
7
- data.tar.gz: 5e4ef4cf71118c020f29b105bb81bb19d753dcb9484f367d0a2caab0b51927e7bcf69e325549bb4e7f44f9f1ec571ffb4223710ca8cc7987dd10eb4750148514
6
+ metadata.gz: 9c46b4f37c08ce6d40158098c5b39006b319a3dab247660a43aa4ebb82ba7527ee9898ccf1513e960abf56a6987dea8b083d9b11b4cff2306d66e5e0b054af03
7
+ data.tar.gz: 4bb9c91a99347f353bcabb17702d13e295f50323173c8fd25fde164af7ac0ea117d38542b9e03449fd386e253f31cd003832310ce5cc5b3f85e4c34978a33fdd
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2026-06-04 14:04:56 UTC using RuboCop version 1.86.1.
3
+ # on 2026-06-09 09:29:01 UTC using RuboCop version 1.86.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,90 +11,13 @@ Gemspec/RequiredRubyVersion:
11
11
  Exclude:
12
12
  - 'glossarist.gemspec'
13
13
 
14
- # Offense count: 6
15
- # This cop supports safe autocorrection (--autocorrect).
16
- # Configuration parameters: EnforcedStyle, IndentationWidth.
17
- # SupportedStyles: with_first_argument, with_fixed_indentation
18
- Layout/ArgumentAlignment:
19
- Exclude:
20
- - 'spec/unit/section_spec.rb'
21
-
22
- # Offense count: 3
23
- # This cop supports safe autocorrection (--autocorrect).
24
- # Configuration parameters: EnforcedStyleAlignWith.
25
- # SupportedStylesAlignWith: either, start_of_block, start_of_line
26
- Layout/BlockAlignment:
27
- Exclude:
28
- - 'spec/unit/section_spec.rb'
29
-
30
- # Offense count: 3
31
- # This cop supports safe autocorrection (--autocorrect).
32
- Layout/BlockEndNewline:
33
- Exclude:
34
- - 'spec/unit/section_spec.rb'
35
-
36
- # Offense count: 1
37
- # This cop supports safe autocorrection (--autocorrect).
38
- Layout/EmptyLineAfterGuardClause:
39
- Exclude:
40
- - 'lib/glossarist/section.rb'
41
-
42
- # Offense count: 1
43
- # This cop supports safe autocorrection (--autocorrect).
44
- Layout/EmptyLines:
45
- Exclude:
46
- - 'Gemfile'
47
-
48
- # Offense count: 2
49
- # This cop supports safe autocorrection (--autocorrect).
50
- # Configuration parameters: EnforcedStyle, IndentationWidth.
51
- # SupportedStyles: special_inside_parentheses, consistent, align_braces
52
- Layout/FirstHashElementIndentation:
53
- Exclude:
54
- - 'spec/unit/section_spec.rb'
55
-
56
- # Offense count: 8
57
- # This cop supports safe autocorrection (--autocorrect).
58
- # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
59
- # SupportedHashRocketStyles: key, separator, table
60
- # SupportedColonStyles: key, separator, table
61
- # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
62
- Layout/HashAlignment:
63
- Exclude:
64
- - 'spec/unit/dataset_register_spec.rb'
65
- - 'spec/unit/section_spec.rb'
66
-
67
- # Offense count: 6
68
- # This cop supports safe autocorrection (--autocorrect).
69
- # Configuration parameters: Width, EnforcedStyleAlignWith, AllowedPatterns.
70
- # SupportedStylesAlignWith: start_of_line, relative_to_receiver
71
- Layout/IndentationWidth:
72
- Exclude:
73
- - 'spec/unit/section_spec.rb'
74
-
75
- # Offense count: 424
14
+ # Offense count: 419
76
15
  # This cop supports safe autocorrection (--autocorrect).
77
16
  # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
78
17
  # URISchemes: http, https
79
18
  Layout/LineLength:
80
19
  Enabled: false
81
20
 
82
- # Offense count: 1
83
- # This cop supports safe autocorrection (--autocorrect).
84
- # Configuration parameters: EnforcedStyle.
85
- # SupportedStyles: symmetrical, new_line, same_line
86
- Layout/MultilineHashBraceLayout:
87
- Exclude:
88
- - 'spec/unit/section_spec.rb'
89
-
90
- # Offense count: 7
91
- # This cop supports safe autocorrection (--autocorrect).
92
- # Configuration parameters: AllowInHeredoc.
93
- Layout/TrailingWhitespace:
94
- Exclude:
95
- - 'spec/unit/dataset_register_spec.rb'
96
- - 'spec/unit/section_spec.rb'
97
-
98
21
  # Offense count: 1
99
22
  # Configuration parameters: AllowedMethods.
100
23
  # AllowedMethods: enums
@@ -116,12 +39,12 @@ Lint/UnusedMethodArgument:
116
39
  Exclude:
117
40
  - 'lib/glossarist/dataset_validator.rb'
118
41
 
119
- # Offense count: 85
42
+ # Offense count: 84
120
43
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
121
44
  Metrics/AbcSize:
122
45
  Enabled: false
123
46
 
124
- # Offense count: 7
47
+ # Offense count: 8
125
48
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
126
49
  # AllowedMethods: refine
127
50
  Metrics/BlockLength:
@@ -142,7 +65,7 @@ Metrics/MethodLength:
142
65
  Metrics/ParameterLists:
143
66
  Max: 6
144
67
 
145
- # Offense count: 38
68
+ # Offense count: 39
146
69
  # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
147
70
  Metrics/PerceivedComplexity:
148
71
  Enabled: false
@@ -154,17 +77,6 @@ Naming/MethodParameterName:
154
77
  Exclude:
155
78
  - 'lib/glossarist/schema_migration.rb'
156
79
 
157
- # Offense count: 5
158
- # This cop supports safe autocorrection (--autocorrect).
159
- # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods.
160
- # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces
161
- # ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object
162
- # FunctionalMethods: let, let!, subject, watch
163
- # AllowedMethods: lambda, proc, it
164
- Style/BlockDelimiters:
165
- Exclude:
166
- - 'spec/unit/section_spec.rb'
167
-
168
80
  # Offense count: 6
169
81
  # This cop supports safe autocorrection (--autocorrect).
170
82
  # Configuration parameters: MaxUnannotatedPlaceholdersAllowed, Mode, AllowedMethods, AllowedPatterns.
@@ -15,6 +15,7 @@ module Glossarist
15
15
  end
16
16
 
17
17
  attribute :ref, Ref
18
+ attribute :text, :string
18
19
  attribute :locality, Locality
19
20
  attribute :link, :string
20
21
  attribute :original, :string
@@ -35,6 +36,10 @@ module Glossarist
35
36
  parts.empty? ? nil : parts.join(" ")
36
37
  end
37
38
 
39
+ def text
40
+ @text || label
41
+ end
42
+
38
43
  def locality_from_yaml(model, value)
39
44
  locality = Locality.new
40
45
 
@@ -67,6 +67,10 @@ module Glossarist
67
67
  doc["terms"] = model.terms&.map(&:to_yaml_hash)
68
68
  end
69
69
 
70
+ def self.detailed_definition_fields
71
+ %i[definition notes examples]
72
+ end
73
+
70
74
  def date_accepted
71
75
  return nil unless dates
72
76
 
@@ -81,18 +85,22 @@ module Glossarist
81
85
 
82
86
  def all_sources
83
87
  list = sources.to_a
84
- definition.each { |d| list.concat(d.sources.to_a) }
85
- notes.each { |n| list.concat(n.sources.to_a) }
86
- examples.each { |e| list.concat(e.sources.to_a) }
88
+ self.class.detailed_definition_fields.each do |field|
89
+ send(field).each { |d| list.concat(d.sources.to_a) }
90
+ end
87
91
  list
88
92
  end
89
93
 
90
94
  def text_content
91
95
  texts = []
92
- definition.each { |d| texts << d.content if d.content }
93
- notes.each { |n| texts << n.content if n.content }
94
- examples.each { |e| texts << e.content if e.content }
96
+ self.class.detailed_definition_fields.each do |field|
97
+ send(field).each { |d| texts << d.content if d.content }
98
+ end
95
99
  texts
96
100
  end
101
+
102
+ def annotations
103
+ @annotations ||= Collections::DetailedDefinitionCollection.new
104
+ end
97
105
  end
98
106
  end
@@ -50,6 +50,7 @@ module Glossarist
50
50
 
51
51
  def load_concept_from_file(filename) # rubocop:disable Metrics/CyclomaticComplexity
52
52
  raw = File.read(filename, encoding: "utf-8")
53
+ self.version = detect_version(raw)
53
54
  doc = concept_document_class.from_yamls(raw)
54
55
  concept = doc.concept
55
56
  unless concept
@@ -166,6 +167,14 @@ module Glossarist
166
167
  end
167
168
  end
168
169
 
170
+ def detect_version(raw)
171
+ if (m = raw.match(/^schema_version:\s*v?(\d)/))
172
+ m[1]
173
+ else
174
+ version
175
+ end
176
+ end
177
+
169
178
  def v1_collection?
170
179
  @v1_collection ||= !Dir.glob(File.join(path,
171
180
  "concept-*.{yaml,yml}")).empty?
@@ -4,10 +4,12 @@ module Glossarist
4
4
  class ConceptRef < Lutaml::Model::Serializable
5
5
  attribute :source, :string
6
6
  attribute :id, :string
7
+ attribute :text, :string
7
8
 
8
9
  key_value do
9
10
  map :source, to: :source
10
11
  map :id, to: :id
12
+ map :text, to: :text
11
13
  end
12
14
  end
13
15
  end
@@ -14,7 +14,7 @@ module Glossarist
14
14
  attribute :pronunciation, Pronunciation, collection: true
15
15
  attribute :sources, ConceptSource, collection: true
16
16
  attribute :term_type, :string
17
- attribute :related, RelatedConcept, collection: true
17
+ attribute :related, DesignationRelationship, collection: true
18
18
 
19
19
  key_value do
20
20
  map :type, to: :type
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Glossarist
4
+ module Designation
5
+ class DesignationRelationship < Lutaml::Model::Serializable
6
+ attribute :content, :string
7
+ attribute :type, :string,
8
+ values: Glossarist::GlossaryDefinition::DESIGNATION_RELATIONSHIP_TYPES
9
+ attribute :target, :string
10
+
11
+ key_value do
12
+ map :content, to: :content
13
+ map :type, to: :type
14
+ map :target, to: :target
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,7 +2,9 @@
2
2
 
3
3
  module Glossarist
4
4
  module Designation
5
- autoload :Base, "glossarist/designation/base"
5
+ autoload :Base, "glossarist/designation/base"
6
+ autoload :DesignationRelationship,
7
+ "glossarist/designation/designation_relationship"
6
8
  autoload :Expression, "glossarist/designation/expression"
7
9
  autoload :Abbreviation, "glossarist/designation/abbreviation"
8
10
  autoload :GrammarInfo, "glossarist/designation/grammar_info"
@@ -26,10 +26,19 @@ module Glossarist
26
26
  dsl.members :pronunciations, link: "gloss:hasPronunciation"
27
27
  dsl.members :sources
28
28
 
29
- RelationshipPredicates::DESIGNATION_REL_PREDICATES.each do |type, (ns, name)|
30
- dsl.predicate name, namespace: ns, to: :"#{type}_targets",
29
+ # Concept-level lexical relationships mapped to designation RDF predicates (URI refs)
30
+ {
31
+ homograph: RelationshipPredicates::DESIGNATION_REL_PREDICATES[:homograph],
32
+ false_friend: RelationshipPredicates::DESIGNATION_REL_PREDICATES[:false_friend],
33
+ }.each do |_type, (ns, name)|
34
+ dsl.predicate name, namespace: ns, to: :"#{_type}_targets",
31
35
  uri_reference: true
32
36
  end
37
+
38
+ # Designation-level relationships (literal target text)
39
+ RelationshipPredicates::DESIGNATION_ONLY_PREDICATES.each do |_type, (ns, name)|
40
+ dsl.predicate name, namespace: ns, to: :"#{_type}_targets"
41
+ end
33
42
  }.freeze
34
43
 
35
44
  DESIGNATION_NAMESPACES = [
@@ -17,6 +17,7 @@ module Glossarist
17
17
  attribute :definitions, GlossDetailedDefinition, collection: true
18
18
  attribute :notes, GlossDetailedDefinition, collection: true
19
19
  attribute :examples, GlossDetailedDefinition, collection: true
20
+ attribute :annotations, GlossDetailedDefinition, collection: true
20
21
  attribute :sources, GlossConceptSource, collection: true
21
22
  attribute :non_verb_reps, GlossNonVerbalRep, collection: true
22
23
 
@@ -55,6 +56,8 @@ module Glossarist
55
56
  link: "gloss:hasNote"
56
57
  members :examples,
57
58
  link: "gloss:hasExample"
59
+ members :annotations,
60
+ link: "gloss:hasAnnotation"
58
61
  members :sources,
59
62
  link: "gloss:hasSource"
60
63
  members :non_verb_reps,
@@ -53,6 +53,10 @@ module Glossarist
53
53
 
54
54
  ALL_REL_PREDICATES = CONCEPT_REL_PREDICATES.merge(DESIGNATION_REL_PREDICATES).freeze
55
55
 
56
+ DESIGNATION_ONLY_PREDICATES = DESIGNATION_REL_PREDICATES.slice(
57
+ :abbreviated_form_for, :short_form_for
58
+ ).freeze
59
+
56
60
  def self.related_targets_by_type(related_concepts, predicate_map)
57
61
  targets = group_targets(related_concepts, predicate_map)
58
62
  predicate_map.each_key.to_h do |type|
@@ -60,6 +64,19 @@ module Glossarist
60
64
  end
61
65
  end
62
66
 
67
+ def self.designation_targets_by_type(relationships, predicate_map)
68
+ valid = Array(relationships).select do |r|
69
+ r.target && predicate_map.key?(r.type.to_sym)
70
+ end
71
+ targets = valid
72
+ .group_by { |r| r.type.to_sym }
73
+ .transform_values { |rs| rs.map(&:target) }
74
+ .transform_keys { |type| :"#{type}_targets" }
75
+ predicate_map.each_key.to_h do |type|
76
+ [:"#{type}_targets", targets[:"#{type}_targets"] || []]
77
+ end
78
+ end
79
+
63
80
  def self.group_targets(related_concepts, predicate_map)
64
81
  valid = valid_related(related_concepts, predicate_map)
65
82
  valid
@@ -120,9 +120,14 @@ module Glossarist
120
120
  build_gloss_designation(desig, concept_id, lang, idx)
121
121
  end
122
122
 
123
- definitions = build_gloss_definitions(data&.definition)
124
- notes = build_gloss_definitions(data&.notes)
125
- examples = build_gloss_definitions(data&.examples)
123
+ dd_attrs = if data
124
+ data.class.detailed_definition_fields.to_h do |field|
125
+ [field, build_gloss_definitions(data.send(field))]
126
+ end
127
+ else
128
+ { definition: [], notes: [], examples: [] }
129
+ end
130
+
126
131
  sources = build_gloss_sources(data&.sources)
127
132
  non_verb_reps = build_gloss_non_verbal_reps(l10n.non_verb_rep,
128
133
  concept_id, lang)
@@ -137,9 +142,7 @@ module Glossarist
137
142
  script: data&.script,
138
143
  system: data&.system,
139
144
  designations: designations,
140
- definitions: definitions,
141
- notes: notes,
142
- examples: examples,
145
+ **dd_attrs,
143
146
  sources: sources,
144
147
  non_verb_reps: non_verb_reps,
145
148
  )
@@ -150,9 +153,9 @@ module Glossarist
150
153
  instance = designation_instance_for(desig, common_attrs, concept_id,
151
154
  lang, index)
152
155
 
153
- rel_targets = Rdf::RelationshipPredicates.related_targets_by_type(
156
+ rel_targets = Rdf::RelationshipPredicates.designation_targets_by_type(
154
157
  desig.related,
155
- Rdf::RelationshipPredicates::DESIGNATION_REL_PREDICATES,
158
+ Rdf::RelationshipPredicates::DESIGNATION_ONLY_PREDICATES,
156
159
  )
157
160
  rel_targets.each do |attr_name, targets|
158
161
  instance.public_send(:"#{attr_name}=", targets) unless targets.empty?
@@ -7,6 +7,8 @@ module Glossarist
7
7
  map :ref, to: :ref, with: { from: :ref_from_yaml, to: :ref_to_yaml }
8
8
  end
9
9
 
10
+ alias_method :text, :label
11
+
10
12
  def ref_from_yaml(model, value)
11
13
  case value
12
14
  when Hash
@@ -15,8 +15,15 @@ module Glossarist
15
15
  attribute :notes, V3::DetailedDefinition,
16
16
  collection: Collections::DetailedDefinitionCollection,
17
17
  initialize_empty: true
18
+ attribute :annotations, V3::DetailedDefinition,
19
+ collection: Collections::DetailedDefinitionCollection,
20
+ initialize_empty: true
18
21
  attribute :related, V3::RelatedConcept, collection: true
19
22
 
23
+ def self.detailed_definition_fields
24
+ super + %i[annotations]
25
+ end
26
+
20
27
  key_value do
21
28
  map :dates, to: :dates
22
29
  map :definition, to: :definition
@@ -25,6 +32,7 @@ module Glossarist
25
32
  map %i[lineage_source_similarity lineageSourceSimilarity],
26
33
  to: :lineage_source_similarity
27
34
  map :notes, to: :notes
35
+ map :annotations, to: :annotations
28
36
  map :release, to: :release
29
37
  map :sources, to: :sources
30
38
  map :terms, to: :terms,
@@ -17,6 +17,7 @@ module Glossarist
17
17
  with: { from: :domains_from_yaml, to: :domains_to_yaml }
18
18
  map :tags, to: :tags
19
19
  map :sources, to: :sources
20
+ map :related, to: :related
20
21
  map :localizations, to: :localizations,
21
22
  with: { from: :localizations_from_yaml, to: :localizations_to_yaml }
22
23
  end
@@ -4,5 +4,5 @@
4
4
  #
5
5
 
6
6
  module Glossarist
7
- VERSION = "2.8.5"
7
+ VERSION = "2.8.7"
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.8.5
4
+ version: 2.8.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-06-04 00:00:00.000000000 Z
11
+ date: 2026-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lutaml-model
@@ -221,6 +221,7 @@ files:
221
221
  - lib/glossarist/designation.rb
222
222
  - lib/glossarist/designation/abbreviation.rb
223
223
  - lib/glossarist/designation/base.rb
224
+ - lib/glossarist/designation/designation_relationship.rb
224
225
  - lib/glossarist/designation/expression.rb
225
226
  - lib/glossarist/designation/grammar_info.rb
226
227
  - lib/glossarist/designation/graphical_symbol.rb