simple_inline_text_annotation 2.0.0 → 2.1.0

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: 8d8d14f48a850c835dbf62083dcda9ea3f2588e7f2544cacf3125e54481fca37
4
- data.tar.gz: 50ebe7c23e5d841697f455586c9ed031d7df4d0da8e625630872948506145b2b
3
+ metadata.gz: afa33452d357e5a3a6c59e9283111d87cad5b3153e97c759e59b98efed7ec18a
4
+ data.tar.gz: 3ad0707815cbad9040153cee41c6e54761f32364bec3c9780f23d7a119c2e2b5
5
5
  SHA512:
6
- metadata.gz: 99e205823a643812b22d835d9b9eae0041e320430b07175ab95a8b87cfb6287d37c749b18eac48beada081c39bb89a3aa16179cbb930e1ef4b426ce5b4ed0334
7
- data.tar.gz: ccd90e14e4b0247428bc271e1663c995126f7361c60c59dfa6a2805fe3d255ef82b73f02ca19ed4beefe0486f3075697a96e389a7577b454d29bdbf19bbe6488
6
+ metadata.gz: 22726d0174ed12d50a435d038d6f78adb2bc51062c692d94704705b511cbaffbbfa47c1b4d997bed6519bcf1eb30dc200fbd8380fc3887444fa5bd45668cf524
7
+ data.tar.gz: 45d9bc60245dc1f91b72f77110ce04b4b00010c674b1b2be61c46f3499683cf392451279cc126e6d24518a14dedfe4919f23615f6a963c8d0267a77096f73d6d
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.1
2
+ TargetRubyVersion: 3.4.4
3
3
  NewCops: enable
4
4
 
5
5
  Style/StringLiterals:
@@ -2,6 +2,7 @@
2
2
 
3
3
  require_relative "entity_type_collection"
4
4
  require_relative "denotation"
5
+ require_relative "relation_without_denotation_error"
5
6
 
6
7
  class SimpleInlineTextAnnotation
7
8
  class Parser
@@ -21,12 +22,10 @@ class SimpleInlineTextAnnotation
21
22
 
22
23
  process_annotations(full_text)
23
24
 
24
- SimpleInlineTextAnnotation.new(
25
- full_text,
26
- @denotations,
27
- @relations,
28
- @entity_type_collection
29
- )
25
+ SimpleInlineTextAnnotation.new full_text,
26
+ @denotations,
27
+ @relations,
28
+ @entity_type_collection
30
29
  end
31
30
 
32
31
  private
@@ -58,6 +57,7 @@ class SimpleInlineTextAnnotation
58
57
  return match.end(0) unless process_annotation(match[2], begin_pos, end_pos)
59
58
 
60
59
  full_text[match.begin(0)...match.end(0)] = target_text
60
+
61
61
  end_pos
62
62
  end
63
63
 
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ class SimpleInlineTextAnnotation
4
+ class RelationWithoutDenotationError < StandardError; end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class SimpleInlineTextAnnotation
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.0"
5
5
  end
@@ -25,6 +25,7 @@ class SimpleInlineTextAnnotation
25
25
  @denotations = denotations
26
26
  @relations = relations
27
27
  @entity_type_collection = entity_type_collection
28
+ check_denotations_and_relations
28
29
  end
29
30
 
30
31
  def self.parse(source)
@@ -70,4 +71,19 @@ class SimpleInlineTextAnnotation
70
71
 
71
72
  { "entity types" => @entity_type_collection.to_config }
72
73
  end
74
+
75
+ def check_denotations_and_relations
76
+ @relations.each do |relation|
77
+ unless referable_to?(relation, @denotations)
78
+ raise SimpleInlineTextAnnotation::RelationWithoutDenotationError,
79
+ "Relation #{relation.inspect} refers to missing denotation."
80
+ end
81
+ end
82
+ end
83
+
84
+ def referable_to?(relation, denotations)
85
+ denotation_ids = denotations.map(&:id)
86
+
87
+ denotation_ids.include?(relation["subj"]) && denotation_ids.include?(relation["obj"])
88
+ end
73
89
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_inline_text_annotation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xaiBUh29wX
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-07-30 00:00:00.000000000 Z
11
+ date: 2025-08-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem provides inline text annotation functionality, extracted from
14
14
  PubAnnotation, with support for denotations, entity types, and nested spans.
@@ -33,6 +33,7 @@ files:
33
33
  - lib/simple_inline_text_annotation/generator_error.rb
34
34
  - lib/simple_inline_text_annotation/parser.rb
35
35
  - lib/simple_inline_text_annotation/relation_validator.rb
36
+ - lib/simple_inline_text_annotation/relation_without_denotation_error.rb
36
37
  - lib/simple_inline_text_annotation/version.rb
37
38
  - sig/simple_inline_text_annotation.rbs
38
39
  homepage: https://github.com/pubannotation/simple_inline_annotation_format
@@ -50,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
50
51
  requirements:
51
52
  - - ">="
52
53
  - !ruby/object:Gem::Version
53
- version: 3.1.0
54
+ version: 3.4.4
54
55
  required_rubygems_version: !ruby/object:Gem::Requirement
55
56
  requirements:
56
57
  - - ">="