text_alignment 0.12.2 → 0.12.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c2a36fe4cfde7dfb76f554fd4afcae7cb5a03e455887621217f5e5e633b20b3
4
- data.tar.gz: f63070c6f423bc15d0fc8c742a21238a104a1b2c1d3fe56ac436effa8ef8eacf
3
+ metadata.gz: 2345340266a0e66e9d26daaa51db1c9239bb837f52a5112a5c525a6d87b120d5
4
+ data.tar.gz: d3d1d118786e89a4bd7f9a6a9315643967c3ae099f8072913862ded9c895bfa5
5
5
  SHA512:
6
- metadata.gz: '078a41bc6ab9b16e7747be6a3bb15aff4b23a1161bcea0b653a93f04d673799afcac2109cd1ce8d1a95c99c5c07d36842e3698c9f0997500e653fb4ab939e04a'
7
- data.tar.gz: ce44d334779d43b3057317537f615ebf39b8049639d3e50c4e14272c952b76a5df2b060cfd3a15f1d28372c11a795ef8bf43cb04de32b5a78ce2f44433edddfb
6
+ metadata.gz: 9fc6c3235373f0e0174a922f006dd2cdf687361dfd567056137d20707b674ae75a40c13862d5a02946a225c19dfdae239ebf3f274a47bb4df1c8b2256bd968e2
7
+ data.tar.gz: 50dede22ed93d9e93a21dbbec5de39f3e342147c512d620a341331c4ddee6d0cd2cd08535e484732fd33e24ec1d8789d4daa7ef79191b13bcb9908634fcafe13
@@ -101,11 +101,11 @@ class TextAlignment::CharMapping
101
101
  end
102
102
 
103
103
  def enmap_position(position)
104
- @index_enmap[position] || raise(ArgumentError, "Unusual position of annotation: #{position}")
104
+ @index_enmap[position]
105
105
  end
106
106
 
107
107
  def demap_position(position)
108
- @index_demap[position] || raise(ArgumentError, "Unusual position of annotation: #{position}")
108
+ @index_demap[position]
109
109
  end
110
110
 
111
111
  def enmap_denotations(denotations)
@@ -113,23 +113,6 @@ class TextAlignment::CharMapping
113
113
 
114
114
  denotations.map do |d|
115
115
  d.dup.merge(span:{begin:enmap_position(d[:span][:begin]), end:enmap_position(d[:span][:end])})
116
- rescue ArgumentError => e
117
- snippet_begin = d[:span][:begin] - 5
118
- if snippet_begin < 0
119
- snippet_begin = 0
120
- end
121
- snippet_end = d[:span][:end] + 5
122
- if snippet_end > @text.length
123
- snippet_end = @text.length
124
- end
125
- snippet = @text[snippet_begin ... d[:span][:begin]] + '[' + @text[d[:span][:begin] ... d[:span][:end]] + ']' + @text[d[:span][:end] ... snippet_end]
126
- if snippet_begin > 0
127
- snippet = '...' + snippet
128
- end
129
- if snippet_end < @text.length
130
- snippet = snippet + '...'
131
- end
132
- raise ArgumentError, e.message + " (#{snippet})"
133
116
  end
134
117
  end
135
118
 
@@ -40,12 +40,12 @@ class TextAlignment::TextAlignment
40
40
  end
41
41
 
42
42
  @mapped_text = @text_mapping.mapped_text
43
- denotations_mapped = @text_mapping.enmap_denotations(denotations)
44
43
 
45
44
  ## To generate the block_alignment of the input text against the reference text
46
45
  @blocks = if r = whole_block_alignment(@mapped_text, @mapped_reference_text, @cultivation_map)
47
46
  r
48
47
  else
48
+ denotations_mapped = @text_mapping.enmap_denotations(denotations)
49
49
  find_block_alignment(@mapped_text, @mapped_reference_text, denotations_mapped, @cultivation_map)
50
50
  end
51
51
 
@@ -343,7 +343,7 @@ class TextAlignment::TextAlignment
343
343
 
344
344
  ## term-based alignment
345
345
  tblocks = if denotations
346
- denotations_in_scope = denotations.select{|d| d[:span][:begin] >= b1 && d[:span][:end] <= e1}.
346
+ denotations_in_scope = denotations.select{|d| d[:span][:begin] && d[:span][:end] && d[:span][:begin] >= b1 && d[:span][:end] <= e1}.
347
347
  sort{|d1, d2| d1[:span][:begin] <=> d2[:span][:begin] || d2[:span][:end] <=> d1[:span][:end] }.
348
348
  map{|d| d.merge(lex:str1[d[:span][:begin] ... d[:span][:end]])}
349
349
 
@@ -1,3 +1,3 @@
1
1
  class TextAlignment
2
- VERSION = '0.12.2'
2
+ VERSION = '0.12.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text_alignment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.2
4
+ version: 0.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jin-Dong Kim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-03 00:00:00.000000000 Z
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-dictionary